How to get the Image URL for an Image Field inside of the Studio
undefined😞
I named the image
imagein my document, and this is what I get:
{
asset: {
_ref: 'image-[hash]-[dimension]-png',
type: 'reference'
},
_type: 'image'
}image.urlis
undefinedand
image.asset.urlis also
undefined
The use case is display the document image for SEO preview in the split preview panel.SEOPreviewcomponent
_refis on
seo.imageand it’s not a filename. it looks like this “image-aecfca21db0ccac083c7df9bad5c6b057d29d97a-3072x1716-png”
@sanity/image-urlmodule: https://github.com/sanity-io/image-url
import client from 'part:@sanity/base/client'Was this answer helpful?
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.