Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

How come images are returning with just a _ref in their assets?

9 replies
Last updated: Feb 3, 2021

How come images are returning with just a _ref in their assets?

Feb 3, 2021, 12:45 AM

This is a reference to the asset in sanity. If you use the url builder, this asset object is all it needs to provide you with the image URL.

Feb 3, 2021, 12:46 AM

I need the url for the image because I’m trying to pass it as a backgroundImage in css, hopefully… if not the ref is fine I suppose

Feb 3, 2021, 12:47 AM

But the component im working on cant use an Img tag as a background I dont think

Feb 3, 2021, 12:47 AM

The URL builder will take the ref and give you the image url

Feb 3, 2021, 12:47 AM

ok

Feb 3, 2021, 12:48 AM

I dont get why I’m getting onyl a ref for this particular image but never for others one.

Feb 3, 2021, 12:48 AM

Hell yeah, it worked thanks

user H

Feb 3, 2021, 1:08 AM

No worries, glad I could help!

Feb 3, 2021, 1:16 AM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.