Trouble getting user-cropped pictures from REST API, resolved with correct image builder usage.

4 replies
Last updated: Jul 26, 2020
I cannot, for the life of me, get the user-cropped pictures - using the UrlBuilder or the REST API directly. I can get the crop and hotspot details from GROQ query, but then I have to apply is all client-side.. I must be missing something.• The default view ignores the asset's user-defined cropping

returns the full size photo
returns a jpeg (should it not return a WEBP?)
Is there any chance it's just not working? That sounds unlikely, seeing as I'm the only one complaining 🤔Should I use the
AssetUtils library instead? It's not quite clear what the difference, if I'm only after the basic functionality of getting the cropped images from the server and applying the hotspot..
Jun 17, 2020, 10:21 AM
I had a similar issue and it turned out I was feeding the image builder the asset (
) instead of the
itself. The image should contain some extra fields like
. I think the image builder passes this to the
and other relevant params.
Jun 17, 2020, 11:00 AM
Somehow, it doesn't break if you do this, but you lose the extra information.
Jun 17, 2020, 11:00 AM
Oh! That did the trick! Geez, that's hours I ain't getting back. Thanks!!
Jun 17, 2020, 1:56 PM
user L
Thanks! This was driving me crazy!
Jul 26, 2020, 1:44 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the 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?

Categorized in