Repository navigation
Fix WebP module: Safari srcset 404s, missing srcset, mixed content - #89
Open
RichKenyon wants to merge 1 commit into
Open
RichKenyon wants to merge 1 commit into
RichKenyon wants to merge 1 commit into
Conversation
- Serve WebP to every browser (filter `wdsbt_serve_webp`, default true) instead of sniffing the navigation Accept header, which Safari leaves without image/webp. One URL now serves one page. - Remove the client-side replaceImagesWithWebP() script (printed three times). Its srcset rewrite dropped each candidate's file extension, so browsers that picked a srcset candidate requested ".../image-768x511 768w" and got a 404. - Stop swapping the src in wp_get_attachment_image_src: core could not match a .webp src to a registered size, so no image got a srcset. The src is swapped in add_webp_source() and each candidate in replace_srcset_with_webp(), after core has built them. - Content and output-buffer passes swap only to a .webp that exists (webp_sibling_url()). - Built and stored URLs follow the request's scheme (set_url_scheme), so an https page never gets http:// images. - dominant-color-images.php: attach the fade-in script to `wdsbt-scripts`; `wp-block-library` is a stylesheet handle, so the script never printed and lazy images stayed at opacity 0.8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012aj8kRbJi5ivGR4soA2g4B
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #88
What this changes
inc/performance/webp-uploads.phpbrowser_supports_webp()returnsapply_filters( 'wdsbt_serve_webp', true )instead of sniffing the navigationAcceptheader. Safari doesn't sendimage/webpthere, and one URL served different HTML per browser.replaceImagesWithWebP()script, which was printed three times. Its srcset rewrite dropped every candidate's file extension, which caused the Safari 404s in the issue.replace_attachment_image_src_with_webp()fromwp_get_attachment_image_src. Swapping the src before core builds the srcset left core unable to match a size, so no image had a srcset. The src is now swapped inadd_webp_source(), and each candidate inreplace_srcset_with_webp(), after core has built them.webp_sibling_url()helper: the content and output-buffer passes now swap only to a.webpthat exists.webp_upload_dir()helper: URLs built fromwp_upload_dir(), and stored WebP URLs, follow the request's scheme, so an https page never gets http:// images.inc/performance/dominant-color-images.phpwdsbt-scripts.wp-block-libraryis a stylesheet handle, so the script never printed and lazy images stayed atopacity: 0.8. The script now also checksreadyState, since a deferred handle can run afterDOMContentLoaded.Testing
composer run-script phpcspasses with no errors or warnings, the same asmain. No JS or CSS files changed.srcorsrcsetURL lacks an extension;<img>tags carry asrcsetagain (none did before in Chrome)..webp..has-dominant-colorimage reachesopacity: 1after it loads.Acceptheader was checked); Windows browsers.