Fix LQIP generation failing for native WebP/AVIF images#976
Merged
Conversation
Refactor logic to strip optimized suffix based on source image extension.
Update filename processing to preserve query strings and fragments.
Collaborator
|
@timotei-litespeed @AsFLY-902 Please give the latest dev a test to make sure this improved version works as expected. |
Contributor
|
@hi-hai from my tests the change is working as expected. One thing I want to notice(not error, images are added to preload ): in page VPI metabox there are differences. V7.9Beta: Notice the .webp added to first image in 7.9 |
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.
Problem
LQIP generation fails for natively uploaded WebP and AVIF images. The
Utility::drop_webp()function unconditionally strips.webp/.avifextensions, which breaks URLs for native WebP/AVIF files that don't have a double extension (e.g.,image.webpvsimage.png.webp).Example:
image.png.webp→image.pngSuccess (LiteSpeed optimized, has source extension)image.webp→imageFails (native WebP, results in 404)This causes the LQIP service to either:
Unsupported response content-type text/html) and add the image to the exclude listFix
Refactored
Utility::drop_webp()to only strip the.webp/.avifsuffix when a valid source extension exists underneath (double-extension pattern like.png.webp). Native WebP/AVIF URLs are now returned unchanged.Changes
src/utility.cls.php— Updateddrop_webp()to usepathinfo()for proper extension detection instead of blindsubstr()stripping.