Hey friends- Is there a way to set the image size in a GROQ query? Looked all over the dos and only see image sizing with the URL builder after the asset is fetched. I have a thumbnail component and would love to only grab a small version. Thanks in advance for any help!
May 24, 2023, 1:30 PM
You fetch the reference and not the asset, then you can build the url with the wanted size and load the asset
May 24, 2023, 1:41 PM
You're only really fetching the image information from groq not a specific size, the url parameters on the image src specify what size image is fetched from Sanity's cdn. (eg.
for 100px wide image) Granted if you wanted to use a url directly from your query result you could do something like this (would need to change based on your schema), I probably wouldn't do this though: