此文章目前僅提供英文版本。

WebPJan 8, 20267 min read

Browser Fallbacks for Modern Image Formats

Modern image formats such as WebP and AVIF can reduce page weight, but delivery still needs a fallback strategy. A fallback is not a sign that modern formats are unsafe. It is a way to make the page explicit, testable, and maintainable across browsers, CMS output, embedded views, and unusual client environments.

The best fallback setup is boring: the browser receives the best supported image, the fallback remains visually correct, and future maintainers can understand which files belong together.

An evergreen claim like "all modern browsers support WebP now" is not permission to ignore fallback behavior. Browser support, embedded webviews, email clients, CMS transforms, CDN cache keys, and enterprise browser policies can all produce exceptions. A fallback strategy should be a testable delivery contract, not a compatibility claim.

Prefer Explicit Markup When Possible#

The HTML picture element lets a page offer multiple sources while keeping a fallback img. MDN's picture element reference explains how browsers evaluate source elements and use the nested image element when no earlier source is selected.

A simple pattern looks like this:

<picture>
  <source srcset="/images/hero.avif" type="image/avif" />
  <source srcset="/images/hero.webp" type="image/webp" />
  <img src="/images/hero.jpg" alt="Product dashboard on a laptop" width="1200" height="800" />
</picture>

This keeps the fallback visible in the markup. It also makes testing easier because each format has a direct URL.

For WordPress sites using GetWebP, this pattern maps to the plugin's picture-tag delivery option. The Frontend Delivery docs explain that GetWebP can wrap images in <picture> with AVIF and WebP sources while preserving the original image as the fallback. That is usually easier to inspect than same-URL negotiation because the relationship between photo.jpg.avif, photo.jpg.webp, and photo.jpg is visible in the HTML.

Keep Fallback Quality Comparable#

A fallback should not be treated as a low-quality leftover. If a browser receives the JPEG or PNG path, the image still represents the product, article, or brand.

Review the fallback for:

  • correct crop
  • current artwork
  • acceptable file size
  • matching alt text context
  • stable width and height
  • visual consistency with the modern format

Teams sometimes update the WebP file and forget the fallback. That creates a split experience where different users see different creative versions.

Use this fallback parity note for important assets:

Asset: pricing-hero
Modern sources: pricing-hero.avif, pricing-hero.webp
Fallback: pricing-hero.jpg
Fallback reviewed: yes
Crop parity: pass
Alt text parity: pass
Fallback file still current: pass
Owner: product marketing

This is especially important for regulated, ecommerce, and product pages where the fallback may still carry claims, packaging, UI screenshots, or promotional details.

Do Not Confuse Format Fallback With Responsive Images#

Format fallback and responsive sizing are related but different. Format fallback answers "which file type can this browser decode?" Responsive images answer "which size should this browser download?"

For production pages, you may need both:

<picture>
  <source
    type="image/webp"
    srcset="/images/card-480.webp 480w, /images/card-960.webp 960w"
    sizes="(max-width: 600px) 90vw, 420px"
  />
  <img
    src="/images/card-960.jpg"
    srcset="/images/card-480.jpg 480w, /images/card-960.jpg 960w"
    sizes="(max-width: 600px) 90vw, 420px"
    alt="Close-up of the product texture"
  />
</picture>

MDN's responsive images guide is useful when combining format choices with width candidates.

Do not mix one responsive set for WebP with a stale or oversized fallback set. A better production pattern keeps both format and size choices aligned:

<picture>
  <source
    type="image/avif"
    srcset="/images/card-480.avif 480w, /images/card-960.avif 960w"
    sizes="(max-width: 600px) 90vw, 420px"
  />
  <source
    type="image/webp"
    srcset="/images/card-480.webp 480w, /images/card-960.webp 960w"
    sizes="(max-width: 600px) 90vw, 420px"
  />
  <img
    src="/images/card-960.jpg"
    srcset="/images/card-480.jpg 480w, /images/card-960.jpg 960w"
    sizes="(max-width: 600px) 90vw, 420px"
    alt="Close-up of the product texture"
    width="960"
    height="640"
  />
</picture>

The fallback is not only the src; the fallback srcset, dimensions, and alt text need to stay current too.

Watch CMS Transformations#

Some CMS platforms rewrite image markup, generate resized files, or apply lazy loading automatically. That can be helpful, but it can also break carefully prepared fallback relationships.

After publishing, inspect the rendered HTML. Confirm that:

  • source elements remain in the expected order
  • MIME types are preserved
  • generated sizes match the intended widths
  • the fallback img still has the correct alt
  • dimensions are present or layout is otherwise stable
  • lazy loading does not delay the main hero image

Never assume the CMS output matches the editor field. The browser only sees the rendered result.

For WordPress, GetWebP's PHP delivery layer rewrites output through filters such as the_content, post_thumbnail_html, and wp_get_attachment_image, with an output-buffer option for remaining images. The same docs note that custom lazy-load libraries using attributes like data-src may need output-buffer delivery. That makes the rendered HTML check part of the quality review, not an optional developer detail.

Rendered-page checklist:

Page: /features/reporting/
Hero image: picture tag present
AVIF source: present and first
WebP source: present and second
Fallback img: current JPEG, correct alt, width and height present
Lazy loading: not applied to main hero
Custom data-src attributes: rewritten or intentionally excluded

Avoid Header Negotiation Unless You Can Test It#

Some systems serve WebP or AVIF from the same URL based on request headers. That approach can work, but it adds cache-key complexity. A CDN must distinguish variants correctly, and debugging becomes harder because the visible URL no longer tells you which format was served.

Explicit URLs are usually easier for smaller teams. Negotiated delivery is more attractive when the platform already handles caching, Accept headers, and content types reliably.

If you use negotiation, verify both modern and fallback clients, and check response headers from the CDN edge, not only from local development.

For same-URL delivery, cache evidence matters. Test both an AVIF/WebP-capable request and a fallback request:

curl -sI -H 'Accept: image/avif,image/webp,image/*,*/*' https://example.com/uploads/hero.jpg
curl -sI -H 'Accept: image/jpeg,image/png,image/*,*/*' https://example.com/uploads/hero.jpg

Record the Content-Type, cache status, and whether the response varies by Accept. GetWebP's WordPress docs cover PHP delivery in Frontend Delivery and same-URL/server behavior in Server Rewrite. The operational risk is not only whether conversion succeeded; it is whether cache and headers route each browser to the right bytes.

Keep File Naming Predictable#

Fallback systems are easiest to maintain when related files share a base name:

product-hero.avif
product-hero.webp
product-hero.jpg
product-hero-640.webp
product-hero-640.jpg

Avoid scattered names such as hero-new.webp, final-banner.jpg, and compressed2.avif. Clear naming helps developers, designers, and content editors avoid pairing the wrong fallback with the wrong modern file.

If files are generated by a batch tool, store the command and output path with the naming convention:

npx -y getwebp ./source-images -o ./public/images --recursive --format webp --json

The GetWebP CLI commands reference documents --output, --recursive, --format, and --json. The JSON output reference documents per-file outputPath and status, which are useful for checking that each modern file has a matching fallback file before deployment.

Test the Failure Path#

Fallback review should include a deliberate failure-path test. Disable a source, test a browser profile without the modern format, or temporarily request the fallback URL directly. Confirm that the page still shows the expected image and does not collapse layout.

Also check network logs. The browser should not download multiple full-size format variants for the same visual slot. If it does, the markup may be wrong.

Use a fallback QA matrix:

TestExpected result
Browser that supports AVIFAVIF candidate selected when available
Browser that supports WebP but not AVIFWebP candidate selected
Browser or crawler path that uses fallbackJPEG/PNG fallback renders correctly
Direct fallback URLcurrent image, correct content type
CDN edge after purgeno stale fallback or stale modern variant
Mobile viewportselected candidate matches displayed slot
Disabled modern source during staginglayout remains stable and fallback appears

This matrix names the failures that teams actually debug after modern-format rollouts.

A Practical Standard#

A reliable fallback standard is simple: modern formats are served where supported, older fallbacks remain visually current, responsive sizing still works, and cache behavior is understandable. Document the pattern once, then apply it consistently across templates.

The documentation record should include:

Fallback pattern: picture tag, AVIF -> WebP -> JPEG
Conversion command: recorded
Generated file naming: same basename per visual
CMS delivery path: rendered HTML inspected
Cache path: CDN headers checked with modern and fallback Accept values
Quality owner: named for hero, product, and brand assets
Rollback: original JPEG/PNG retained

WebP and AVIF are useful tools, but they should be delivered through markup and caching rules that future maintainers can inspect. Good fallbacks protect the user experience while letting teams adopt modern formats with less operational risk.

Jack avatar

Jack

GetWebP Editor

Jack writes GetWebP guides about local-first image conversion, WebP workflows, browser compatibility, and practical performance checks for teams that publish images on the web.