Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref and _type and I need the url, I don't want to use...

3 replies
Last updated: Dec 1, 2020

Hi, I need help with a query for getting the url of an image asset.Here is what I've been trying, but I only get the _ref and _type and I need the url, I don't want to use urlFor() function because it is not an option for what I'm trying to achieve.

Dec 1, 2020, 9:41 AM

Why is urlfor not an option?

Dec 1, 2020, 12:09 PM

I need the data on a server side with minimal external package usages, why does that matter?

Dec 1, 2020, 2:02 PM

Could you try replacing this:

images[] ->{..., resourceFileImage->{image_asset->{'asset': asset->{path,url}}}}
With something like this?

images[] ->{..., 'asset': image_asset.asset->{path,url}}

Dec 1, 2020, 3:53 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.