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.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.