Extracting referenced images from an object array in Sanity.io

3 replies
Last updated: May 17, 2020
Hey, I have a reference array to an object with bits of information (called socials), mainly text, and then inside socials I have another reference to an image document. On the front end :`*[_type == "header"]{logo, invertedLogo, menu, socials}` any tips on how would I go about extract that referenced image from socials to the imgBuilder and extracting the rest of the information from socials at the same time?
May 17, 2020, 5:53 PM
socials{image->asset._ref} or something like it ๐Ÿ™‚
May 17, 2020, 6:06 PM
Thank you, doing socials[]{...otherinfo, image[]->{image}} worked
May 17, 2020, 6:24 PM
it feels like I could do it in less steps but at least it works ๐Ÿ™‚
May 17, 2020, 6:26 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?