Can't Get Image URL Inside Asset.Ref

4 replies
Last updated: Feb 25, 2022
Im trying to post the images from the array in a carousel, but i cant get hold of the image url inside asset.ref?? any clue what to do?
Feb 25, 2022, 5:46 PM
You need a projection in your groq query: https://www.sanity.io/docs/presenting-images#BnS1mFRw
Feb 25, 2022, 5:49 PM
It's confusing when you first encounter it but, inside of a document an image field is actually a reference to an asset in your Content Lake. When you're querying for it, you need to expand that asset. For example:
<image-field> {
  ...,
  asset->
}
Feb 25, 2022, 5:50 PM
right! fixed it ๐Ÿ˜„
Feb 25, 2022, 6:00 PM
right! fixed it ๐Ÿ˜„
Feb 25, 2022, 6:00 PM

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.

Was this answer helpful?