Trouble with imageUrlBuilder not respecting hotspot and crop values in Sanity.io.

3 replies
Last updated: Jun 11, 2024
Tough time with the imageUrlBuilder (@sanity/image-url). It works fine to retrieve the image and manipulate it (set width/height flipping it etc...) but does not respect the
hotspot
and
crop
values I set in the studio.I've seen that the way the imageUrlBuilder works it by passing a SanityImageSource, which simply has a reference to the image document stored in the studio. How is it supposed to retrieve hotspot and crop values?
May 20, 2024, 12:18 PM
I figured this out, for anyone wondering, I was passing the asset data contained in the image directly in the imageUrlFor() function. This will load the image, but won't use the crop/hotspot. Feeding the whole image object, conatining the asset, hotspot and crop data to imageUrlFor() instead of solely the asset will fix this.
May 20, 2024, 2:02 PM
Thanks for sharing your solution!
May 20, 2024, 3:35 PM
user K
So you're not using <SanityImage>?
Jun 11, 2024, 1:38 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?