Skip to content

WebP uploads are not converted to AVIF when fallback output is enabled #2760

Description

@b1ink0

Bug Description

When "AVIF" is selected and "Also generate fallback images in the original upload format" is enabled, uploading a WebP image creates no AVIF images at all. The full size and every sub-size stay WebP only.

With fallback output disabled, the same WebP upload is converted to AVIF as expected. JPEG and PNG uploads get their AVIF versions with fallback output enabled as well, so only WebP uploads are affected.

Steps to reproduce

  1. Make sure the server supports AVIF.
  2. Go to Settings > Media.
  3. Select "AVIF" in "Image output format".
  4. Enable "Also generate fallback images in the original upload format" and save the changes.
  5. Upload a WebP image in the Media Library.
  6. See that no AVIF files are created for the image, and its metadata has no image/avif sources.

Expected: an AVIF version of the full size and each sub-size is generated, and the uploaded WebP is kept as the fallback, the same as for JPEG and PNG uploads. As with JPEG and PNG uploads, an AVIF that is not smaller than the original is discarded.

Additional Context

  • Plugin Version: 2.7.1

Activity

  1. added this to the webp-uploads n.e.x.t milestone on Nov 17, 2026
  2. added
    [Type] Bug
    on Nov 17, 2026
  3. added theissue type on Nov 17, 2026
  4. added
    [Plugin] Modern Image Formats
    on Nov 17, 2026
  5. moved this to Not Started/Backlog 📆 in WP Performance Ongoingon Nov 17, 2026
  6. b1ink0 commented on Nov 17, 2026

    @b1ink0
    ContributorAuthor

    This will be surfaced after issue #2745 is resolved. Currently, even with the fix in the PR, the generated AVIF image will most likely be larger than its WebP counterpart due to the default AVIF quality setting.

  7. b1ink0 commented on Nov 17, 2026

    @b1ink0
    ContributorAuthor

    While working on this, it was not clear what fallback output should do when the upload is already WebP or AVIF. With fallback output enabled, this is what each upload gets today:

    Upload "WebP" selected "AVIF" selected
    JPEG JPEG and WebP JPEG and AVIF
    PNG PNG and WebP PNG and AVIF
    WebP WebP and JPEG WebP only (this issue)
    AVIF AVIF only AVIF and JPEG

    Each generated file is only kept when it is smaller than the uploaded image, so the JPEG for a WebP or AVIF upload is only kept for the sizes where it is smaller than the upload.

    A few things stand out:

    • A WebP upload gets a JPEG when "WebP" is selected, and an AVIF upload gets a JPEG when "AVIF" is selected. But a WebP upload with "AVIF" selected, and an AVIF upload with "WebP" selected, get no other format at all.
    • The JPEG is generated even for transparent images, so a transparent WebP or AVIF loses its transparency in the JPEG.
    • The setting says "Also generate fallback images in the original upload format". A WebP or AVIF upload is already a modern format, so the original upload could be the fallback itself.

    What should fallback output do for WebP and AVIF uploads?

    1. Keep the original upload as the fallback, as the setting describes. Only the selected format is added: a WebP upload with "AVIF" selected gets AVIF, an AVIF upload with "WebP" selected gets WebP, and an upload in the selected format gets nothing extra. No JPEG is generated, so transparency is never lost.
    2. Add a widely supported fallback to every WebP and AVIF upload: JPEG, or PNG for transparent images, along with the selected format.

    The PR for this issue follows option 1 for WebP uploads with "AVIF" selected. The other cases can be aligned in a follow-up once the approach is decided.

    🤖 Generated with Claude Code

    cc: @adamsilverstein

  8. adamsilverstein commented on Nov 17, 2026

    @adamsilverstein
    Member

    WebP upload gets a JPEG when "WebP" is selected

    That does seem unexpected, I would at first glance expect all files to be WebP, similar to AVIF generating only AVIF.

    However,

    Since all modern browsers now support AVIF and WebP, the only reason you would want to enable the "fallback" I can think of would be to support older browsers. In that case, I feel like you would actually want a JPEG fallback for modern images.

    Therefore I would like to reconsider how this feature works:

    Two proposals -

    1. Drop the feature (my recommendation)
    • we could greatly simplify the plugin by dropping support for generating fallback images entirely. maybe i'm wrong, but I feel like this feature isn't something most people should use. If they don't want to serve modern images, they shouldn't enable the plugin.
    • This would also remove the picture mode implementation, further simplifying the plugin
    1. Keep the feature, with jpeg as the fallback format (always)
    • This keeps the one reason users might want the feature - generate a modern format (webp, avif) and a fall back to a legacy format (jpeg)
    • The why and what of enabling this can be added near the settings toggle

    cc: @westonruter

  9. westonruter commented on Nov 18, 2026

    @westonruter
    Member

    @adamsilverstein The main reason for the fallback is actually for external services like social media providers and Google Search which may not support the modern formats, no?

  10. adamsilverstein commented on Nov 19, 2026

    @adamsilverstein
    Member

    The main reason for the fallback is actually for external services like social media providers and Google Search which may not support the modern formats, no?

    Good point, I remember those conversations now. I would say we should research what those services/sources/plugins use for things like core or plugin feeds, featured images and og or other meta tags, they may just be using the original upload. A little research would be good here to make sure the current approach does what we expect and maybe better document the WHY part.

    In any case I could see how you might want to avoid modern images in those places so its a reasonable argument for keeping the fallback.

    So if we want to keep the fallback format feature around, I would still say the default output fallback format should always be jpeg since it is the most compatible, wdyt @westonruter?

  11. westonruter commented on Nov 19, 2026

    @westonruter
    Member

    Yes, the fallback should always be JPEG (or PNG).

  12. b1ink0 commented on Nov 23, 2026

    @b1ink0
    ContributorAuthor

    I did the research as suggested, starting with what SEO plugins and core actually output.

    I checked Yoast SEO, Rank Math, All in One SEO, SEOPress, The SEO Framework, Slim SEO and Jetpack, plus the REST API, oEmbed and the RSS feed. All of them use the attachment's attached file. None of them read the sources metadata.

    So Adam's guess was close. With fallback on, the attached file is still the original JPEG or PNG, so that's what gets shared. With fallback off, the attached file is the WebP or AVIF, so that's what gets shared instead.

    Upload Fallback off Fallback on
    JPEG selected format JPEG
    PNG selected format PNG
    WebP selected format WebP
    AVIF ("WebP" selected) AVIF AVIF

    The catch is WebP and AVIF uploads. Any JPEG the fallback makes for them only ends up in sources, so no external service ever sees it.

  13. b1ink0 commented on Nov 23, 2026

    @b1ink0
    ContributorAuthor

    Next, I wanted to know if social apps actually show WebP and AVIF in link previews. Facebook and LinkedIn only list JPEG, PNG and GIF in their docs, so I tested real shares instead of relying on the docs.

    I made a test page for each image format (JPEG, PNG, WebP and AVIF, plus transparent PNG, WebP and AVIF), each using that image as its og:image and twitter:image. Then I shared the links in each app on real phones (Android, plus an iPhone for iMessage) and checked whether the preview showed the image. I also sent the same images in an email to Gmail and Outlook. The test pages logged every request, so I could confirm each app really downloaded the image and wasn't showing an old cached preview.

    • JPEG, PNG and WebP previews worked in every app I tried.
    • AVIF showed no image in 6 of the 13 apps: Telegram, Slack, LinkedIn, Bluesky, iMessage and X. Most of them downloaded the AVIF and then couldn't display it.

    Full results:

    App JPG PNG WebP AVIF Transparent PNG Transparent WebP Transparent AVIF
    Facebook ✅ ✅ ✅ ✅ ✅ kept ✅ kept ✅ kept
    WhatsApp ✅ ✅ ✅ ✅ ⚠️ white fill ⚠️ white fill ⚠️ white fill
    Signal ✅ ✅ ✅ ✅ ⚠️ black fill ⚠️ black fill ⚠️ black fill
    Threads ✅ ✅ ✅ ✅ ✅ kept ✅ kept ✅ kept
    Reddit ✅ ✅ ✅ ✅ ✅ kept ✅ kept ✅ kept
    Google Messages (RCS) ✅ ✅ ✅ ✅ ✅ kept ✅ kept ✅ kept
    Discord ✅ ✅ ✅ ✅ ✅ kept ✅ kept ✅ kept
    Telegram ✅ ✅ ✅ ❌ ⚠️ white fill ⚠️ white fill ❌
    Slack ✅ ✅ ✅ ❌ ✅ kept ✅ kept ❌
    LinkedIn ✅ ✅ ✅ ❌ ❓ gray ❓ gray ❌
    Bluesky ✅ ✅ ✅ ❌ ⚠️ black fill ⚠️ black fill ❌
    iMessage ✅ ✅ ✅ ❌ placeholder icon ✅ kept ✅ kept ❌ placeholder icon
    X ✅ ✅ ✅ ❌ broken image ✅ kept ⚠️ white fill ❌ broken image
    Gmail (email) ✅ ✅ ✅ ✅ ✅ kept ⚠️ black fill ✅ kept
    Outlook (email) ✅ ✅ ✅ ✅ ✅ kept ✅ kept ✅ kept
    • ✅ the image was shown, ❌ no image was shown.
    • kept: the transparent area matches the card around it. white fill / black fill: the service flattened the image onto that color. ❓ gray: LinkedIn shows it on a gray tile.

    A JPEG fallback loses transparency everywhere, so the "or PNG" part matters. Some services flatten transparent images on their own anyway (WhatsApp and Telegram onto white, Signal and Bluesky onto black), but that happens for PNG and WebP alike and isn't something we can fix.

    So I'd keep the feature. Without it, an AVIF site shares broken previews on a lot of popular services.

  14. adamsilverstein commented on Nov 23, 2026

    @adamsilverstein
    Member

    Thanks for the research @b1ink0!

    Especially appreciate the social feed testing, I went searching for that information and it was very difficult to tell what was really current or accurate. Your confirmation that the feature actually helps is great.

    Could we improve the documentation around this feature or what the button says when you enable it so it is clear why you would use it?

  15. b1ink0 commented on Nov 24, 2026

    @b1ink0
    ContributorAuthor

    More data so a decision can be taken on the direction for the fallback settings.

    I revisited the "always JPEG (or PNG)" with the data above, since we agreed on it before we had any of it.

    The fallback does two things. It's what SEO plugins, feeds and share previews see, because they only read the attached file and its sub-sizes. And it's the <img> inside <picture> for browsers without WebP or AVIF support. For the first one, WebP worked in every app I tested. Only AVIF failed. So for sharing, it's really only AVIF that needs a fallback.

    Here's what WebP and AVIF uploads get today with fallback on:

    Upload "WebP" selected "AVIF" selected
    WebP WebP, plus a JPEG in sources WebP only (this issue)
    AVIF AVIF only AVIF, plus a JPEG in sources

    The JPEG only ever lands in sources, so no share preview sees it. An AVIF upload with "WebP" selected never gets a WebP, with fallback on or off, because AVIF uploads aren't converted to WebP at all.

    Instead of making a JPEG or PNG from a WebP or AVIF, I'd like to propose this:

    Upload Attached file and sub-sizes In sources
    JPEG or PNG the original, same as today WebP or AVIF
    WebP, "WebP" selected the WebP, no JPEG nothing extra
    WebP, "AVIF" selected the WebP AVIF
    AVIF a WebP made from it the AVIF

    So nothing gets converted down to a lower-quality JPEG, transparency is always kept, and no transparency check is needed. AVIF never ends up in a share preview, and JPEG and PNG uploads work exactly as they do now.

    The trade-offs:

    • Browsers without WebP support wouldn't get a JPEG for WebP and AVIF uploads. Today they only get one in picture element mode, and only when the JPEG came out smaller than the upload.
    • Gmail flattened a transparent WebP, while they kept a transparent PNG.
    • For AVIF uploads, the WebP will often be bigger than the AVIF, so they'd use more storage.

    Two questions:

    1. Is WebP fine as the fallback for AVIF, instead of JPEG or PNG?

    2. Should the fallback be the attached file and every sub-size, and be kept even when it's bigger than the upload?

    SEO plugins and core never read sources, so the fallback only helps sharing if it's the attached file. It also has to be every sub-size. I uploaded three large JPEGs and checked which file each plugin puts in og:image:

    Plugin 2560px, 1 MB 2000px, 4.8 MB 2400px, 9.6 MB How it picks
    Yoast SEO full large large First of full, large, medium_large under 2 MB
    Rank Math large full large First of full, large, medium_large between 200 and 2000px
    The SEO Framework full full 2048x2048 Largest size within 4096px and 5 MB
    All in One SEO full full full full
    SEOPress full full full full
    Slim SEO full full full full
    Jetpack full full full full

    Core does the same. The oEmbed thumbnail_url was medium_large for all three, and the RSS feed uses whatever size the image block uses. Since a normal photo gets scaled to 2560px, Rank Math will share the large size for most uploads.

    Right now any generated file that isn't smaller than the upload is dropped. A WebP made from an AVIF will often be bigger, so with that check some sizes would end up with no fallback.

    🤖 Generated with Claude Code

  16. adamsilverstein commented on Nov 24, 2026

    @adamsilverstein
    Member

    Two questions:

    1. Is WebP fine as the fallback for AVIF, instead of JPEG or PNG?

    Probably, it has wide enough adoption now that it should work (nearly) everywhere. Do you agree?

    I do always think of this meme (which is now slightly outdated):

    image

    2. Should the fallback be the attached file and every sub-size, and be kept even when it's bigger than the upload?

    Probably if you have the fallback mode the default should be keeping all the images regardless of their relative sizes.

    Right now any generated file that isn't smaller than the upload is dropped.

    I never liked this approach, this should be an opt in behavior. Its better to have each size generated so you have it when you need it (current case for example), I would propose changing the default.

    SEO plugins and core never read sources, so the fallback only helps sharing if it's the attached file. It also has to be every sub-size.

    So to confirm: currently none of these plugins will use the fallback images and if users are outputting AVIF some services may not be able to use their images. eg, a feed of posts into a slack channel?

    I was actually surprised to see how good the existing WebP and even AVIF coverage is in your charts. We will be adding JXL soon though, which will add another new flavor to the mix.

    I uploaded three large JPEGs and checked which file each plugin puts in og:image:

    Plugin 2560px, 1 MB 2000px, 4.8 MB 2400px, 9.6 MB How it picks
    Yoast SEO full large large First of full, large, medium_large under 2 MB
    Rank Math large full large First of full, large, medium_large between 200 and 2000px
    The SEO Framework full full 2048x2048 Largest size within 4096px and 5 MB
    All in One SEO full full full full
    SEOPress full full full full
    Slim SEO full full full full
    Jetpack full full full full

    Do these plugins operate in a consistent enough way that we could filter the response to always provide the fallback image? I'm certain we could do that core feeds for example. maybe images requested outside the content would automatically get the fallback image?

    Making this work automatically would make the whole fallback image feature genuinely valuable.

    Right now any generated file that isn't smaller than the upload is dropped. A WebP made from an AVIF will often be bigger, so with that check some sizes would end up with no fallback.

    Enabling the fallback feature should imply every image is generated, we should document that and change the default to keeping all images.

  17. b1ink0 commented on Nov 24, 2026

    @b1ink0
    ContributorAuthor

    Probably, it has wide enough adoption now that it should work (nearly) everywhere. Do you agree?

    Yes. WebP showed up in every app I tested, 13 link previews plus Gmail and Outlook. The only differences were with transparency: Gmail turned a transparent WebP into a black background (caniemail notes Gmail "Converts file to jpg" for WebP), while kept a transparent PNG. A JPEG would lose transparency everywhere, so WebP is still the better fallback.

    The test pages are on GitHub Pages if anyone wants to try a service I missed: https://b1ink0.github.io/research-lab/link-preview-formats/site/

    I would propose changing the default.

    Agreed.

    So to confirm: currently none of these plugins will use the fallback images and if users are outputting AVIF some services may not be able to use their images. eg, a feed of posts into a slack channel?

    Mostly, with one nuance. For JPEG and PNG uploads with fallback on, they do use the fallback today, because the original JPEG or PNG stays the attached file. What they never see is the JPEG made for WebP and AVIF uploads, since that only goes into sources.

    The bigger problem is the defaults. AVIF is the default format (settings.php#L33), and fallback is off unless the theme declares html5 picture support (settings.php#L43). So on most sites every JPEG upload becomes an AVIF attached file, and that's what gets shared.

    For Slack: shared links to a page with an AVIF og:image showed no image, and Slack's image proxy never even downloaded the AVIF. I haven't tested the Slack RSS app, but the core feed has the same problem. With fallback off the feed <img> is the .avif, and with fallback on a JPEG upload gives the .jpg.

    Do these plugins operate in a consistent enough way that we could filter the response to always provide the fallback image? I'm certain we could do that core feeds for example. maybe images requested outside the content would automatically get the fallback image?

    The plugin already works this way. It only swaps in the modern format for <img> tags in the page body. webp_uploads_in_frontend_body() skips REST, XML-RPC, feeds and anything printed inside wp_head, which is where the SEO plugins print their tags. Everything outside the content already gets the attached file. That's why JPEG and PNG uploads with fallback on work in all seven plugins, the REST API, oEmbed and the feed, with no code for any of them.

    So the missing piece isn't a filter. It's making sure the attached file is the fallback for every upload. I'd avoid filtering wp_get_attachment_image_src() or wp_get_attachment_url():

    • Themes and blocks call the same functions for the page itself, and nothing in the call says whether it's for a share tag or for the page.
    • Yoast and Rank Math take og:image:type from the attachment's post_mime_type, and Yoast and The SEO Framework pick a size by the file size stored in the metadata. A swapped URL wouldn't match either one.
    • The SEO Framework reads the sizes metadata directly for large images (utils.class.php#L128), so a URL filter wouldn't cover it.

    If the attached file and every sub-size are the fallback, it also works for plugins I didn't test, headless sites, page builders and email tools.

    All the scripts and data are here, with Docker to reproduce it: https://github.com/b1ink0/research-lab/tree/main/wp-image-fallbacks

  18. adamsilverstein commented on Nov 24, 2026

    @adamsilverstein
    Member

    Mostly, with one nuance. For JPEG and PNG uploads with fallback on, they do use the fallback today, because the original JPEG or PNG stays the attached file.

    Ah, ok this make way more sense. I missed that part previously. This is honestly the most common use case: users are uploading their JPEG originals and using the plugin to convert those to WebP or AVIF to optimize their site. Its good that we cover this case by default, thats going to be the biggest benefit to users.

    What they never see is the JPEG made for WebP and AVIF uploads, since that only goes into sources.

    Ah, right. It would be nice to fix that.

    The bigger problem is the defaults. AVIF is the default format

    Given what users install the plugin for, the AVIF default seems right, maybe the fallback generation should also be on by default though?

    The plugin already works this way.

    Oh good :)

  19. b1ink0 commented on Nov 26, 2026

    @b1ink0
    ContributorAuthor

    Related to the SEO plugin results: with fallback off, Yoast and Rank Math output the wrong og:image:type. A JPEG upload is shared as the .avif file, but og:image:type is image/jpeg.

    Both take og:image:type from the attachment's post_mime_type. Core keeps the original post_mime_type when an image_editor_output_format filter changes the format, which is how the plugin converts uploads (hooks.php#L335-L364).

    WordPress/wordpress-develop#16277 updates the attachment's MIME type in core when the format changes which is a old bug.

  20. Ix3WUhpgTPE commented on Dec 3, 2026

    @Ix3WUhpgTPE

    It seems like the image editor might be identifying the WebP source as an identical match to the intended output format, causing the process to short-circuit before reaching the generation stage. I suspect the issue lies in the conditional logic inside the image editor's save method where it checks the mime types; specifically, it likely treats WebP as both the source and the fallback, causing the AVIF conversion to be skipped entirely. Could you check if the wp_generate_attachment_metadata filter is returning early when it detects a WebP source during the fallback generation loop? Adding a conditional check to ensure is_intermediate_image logic still triggers AVIF conversion even when the fallback is enabled should resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Plugin] Modern Image Formats[Type] Bug

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions