&max-w=200 - Limiting Maximum Image Width
The max-w parameter only works when you also specify fit=crop. According to Sanity's image transformations documentation, the max-w parameter is described as:
"Maximum width in the context of image cropping. Specifies size limits giving the backend some freedom in picking a size according to the source image aspect ratio. This parameter only works when also specifying
fit=crop."
So to make max-w=200 work, you need:
?max-w=200&fit=crop
The reason w=200 works on its own is that it doesn't have this requirement—it works with any fit mode or the default behavior.
Why does max-w require fit=crop?
The max-w parameter is specifically designed for cropping scenarios where you want to set upper bounds on dimensions while giving the image pipeline flexibility to choose the final size based on the source image's aspect ratio. It's part of a set of min/max parameters (min-w, min-h, max-w, max-h) that all require fit=crop.
What if you don't want cropping?
If you want to constrain the maximum width without cropping, use w=200&fit=max instead. The fit=max parameter ensures the image fits within the dimensions you specify but never scales up—images smaller than 200px stay their original size, while larger ones scale down proportionally.
Other useful fit values for width constraints:
fit=clip- Resizes to fit within bounds without cropping or distortion (default)fit=max- Fits within the box, never scaling upfit=scale- Scales to exact dimensions (may distort aspect ratio)fit=fill- Like clip, but fills empty space with a background color (use withbgparameter)
No additional configuration is needed in your Sanity project—these parameters work out of the box with any Sanity image URL from the CDN.
Show original thread1 reply
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.