Sanity image URL: Specify fallback format when browser doesn't support webp

6 replies
Last updated: Jan 28, 2026
Hi, quick question:when generating a url for my images in the front-end there’s the option to use
auto=format
to automatically use
webp
as image format if the browser supports it. is there a way to specify a fallback format (eg i want to use
jpg
if the original image file is uploaded as
png
) if the browser doesn’t?
AI Update

Based on Sanity's image transformation documentation, there isn't a built-in fallback format parameter when using auto=format.

Here's how auto=format works:

When you use ?auto=format, Sanity automatically serves the most optimized format based on the browser's Accept header:

  • WebP for browsers that support it
  • AVIF for browsers that support it (though this is generated asynchronously, so the first few requests might get WebP instead)
  • Falls back to PNG/JPG depending on the original source image format if the browser doesn't support modern formats

The key point: The fallback is determined by your original uploaded image format, not by a parameter you can specify. If you upload a PNG, browsers that don't support WebP/AVIF will get PNG. If you upload a JPG, they'll get JPG.

Your options:

  1. Control the fallback by choosing your upload format: Upload your images as JPG if you want JPG as the fallback format for browsers that don't support WebP/AVIF.

  2. Use the fm parameter explicitly: Instead of auto=format, you can specify the format directly with fm=jpg or fm=webp, but this means you lose the automatic format selection benefit.

  3. Handle it client-side: Use picture elements with multiple source tags to specify your own fallback chain:

    <picture>
      <source srcset="image.jpg?fm=webp" type="image/webp">
      <source srcset="image.jpg?fm=jpg" type="image/jpeg">
      <img src="image.jpg?fm=jpg" alt="...">
    </picture>

Unfortunately, there's no single parameter like ?auto=format&fallback=jpg in Sanity's image pipeline. The fallback format is inherently tied to your source image format when using auto=format.

Show original thread
6 replies

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.

Was this answer helpful?