Make WordPress Core

Opened 13 months ago

Last modified 12 months ago

#56529 new enhancement

Add minimal JPEG fallback script to address limited lack of WebP support

Reported by: flixos90's profile flixos90 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch has-unit-tests
Focuses: Cc:


As noted in the original ticket #55443, there is still a very small global percentage of browser usage (between 1% and 3%) where the browser does not support WebP. Most of that is comprised of Safari on certain outdated versions of Mac OS and iOS.

A pull request for this has been already in the works for the previously envisioned multi MIME type infrastructure (see e.g., and while this infrastructure has been reverted, most of the code for the fallback script is still relevant, so the PR can probably be continued and only has to be adjusted to the new circumstances where every image size has either WebP or JPEG available.

The new approach here for the fallback needs to be as follows (when WebP is not supported): Choose the smallest available version of the image that has at least as large dimensions as the WebP version and has the same aspect ratio.

Change History (3)

This ticket was mentioned in PR #3034 on WordPress/wordpress-develop by mukeshpanchal27.

13 months ago

  • Keywords has-patch has-unit-tests added

The PR adds fallback JPEG images in the frontend when WebP is not supported by the browser.

Trac ticket:

### BrowserStack testing results for different browsers and devices.
Random browsers and devices:
Mac OS & Windows & Android devices:
iOS iPhone and iPad devices:

felixarntz commented on PR #3034:

13 months ago

@mukeshpanchal27 This is now ready to proceed, however it has to be updated to the new approach where only WebP or JPEG is available per image size. No sources data is present anymore, so this needs to be fully dependent on the single image that is available for each size. I've opened a new Trac ticket specifically for this functionality:

I believe most of the code in this PR can remain unchanged. The two main things that need to be updated are:

  • The wp_image_use_alternate_mime_types() function no longer exists. So we need to handle setting the global $_wp_image_mime_fallback_should_load in a different way. Since we now no longer do frontend replacements of JPEG at all, I suggest we instead incorporate this somewhere into wp_filter_content_tags() or potentially a new helper function where we check whether the content includes any .webp image, and if so set the global so that the minimal fallback script is included.
  • The actual JS code in the wp-image-mime-fallback.js script needs to be changed according to the new conditions. We will now have to replace every WebP version with the best available JPEG version, which is
    • the smallest available JPEG with at least the dimensions of the WebP
    • using the same aspect ratio

cc @adamsilverstein

#3 @davidbaumwald
12 months ago

  • Milestone changed from 6.1 to Future Release

After chatting with @flixos90 and the revert(r54226) of the main WebP generation feature for 6.1, moving this to Future Release for continued work.

Note: See TracTickets for help on using tickets.