Quick way to receive image dimensions in Sanity projects

8 replies
Last updated: Apr 20, 2020
hey team - hope all is well. i was curious if there is a quick way to receive dimensions for my images in my
._type=project
from sanity like you get back in
._type=sanity.imageAsset?
Apr 20, 2020, 7:00 PM
Yes, you just have to resolve the image.
Apr 20, 2020, 7:01 PM
can you provide an example? i'm assuming it may be similar to the way i am resolving service refs
Apr 20, 2020, 7:01 PM
"cover": cover,
"continents": continents[]->title,
Apr 20, 2020, 7:02 PM
"coverDimensions": cover[]->metadata
?
Apr 20, 2020, 7:02 PM
this is resolving to nothing. any guidance would be appreciated - the cheat sheet isn't outlining clearly how to break down the image asset
Apr 20, 2020, 7:06 PM
figured it out for anybody else needing help:
*[_type=='project']{cover{asset->{path,url,metadata}}}

thanks!
Apr 20, 2020, 7:07 PM
πŸ‘
Apr 20, 2020, 7:08 PM

Sanity– build remarkable experiences at scale

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

Was this answer helpful?