Skip to content

Fix LQIP generation failing for native WebP/AVIF images#976

Merged
hi-hai merged 3 commits into
litespeedtech:devfrom
AsFLY-902:LQIP-fix
Jul 2, 2026
Merged

Fix LQIP generation failing for native WebP/AVIF images#976
hi-hai merged 3 commits into
litespeedtech:devfrom
AsFLY-902:LQIP-fix

Conversation

@AsFLY-902

Copy link
Copy Markdown

Problem

LQIP generation fails for natively uploaded WebP and AVIF images. The Utility::drop_webp() function unconditionally strips .webp/.avif extensions, which breaks URLs for native WebP/AVIF files that don't have a double extension (e.g., image.webp vs image.png.webp).

Example:

  • image.png.webpimage.png Success (LiteSpeed optimized, has source extension)
  • image.webpimage Fails (native WebP, results in 404)

This causes the LQIP service to either:

  1. Get a 404 response and add the image to the exclude list
  2. Receive an HTML error page instead of image data (Unsupported response content-type text/html) and add the image to the exclude list

Fix

Refactored Utility::drop_webp() to only strip the .webp/.avif suffix 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 — Updated drop_webp() to use pathinfo() for proper extension detection instead of blind substr() stripping.

AsFLY-902 and others added 3 commits May 7, 2026 10:54
Refactor logic to strip optimized suffix based on source image extension.
Update filename processing to preserve query strings and fragments.
@hi-hai
hi-hai merged commit 8ac653a into litespeedtech:dev Jul 2, 2026
1 check passed
@hi-hai

hi-hai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

@timotei-litespeed @AsFLY-902 Please give the latest dev a test to make sure this improved version works as expected.

@timotei-litespeed

Copy link
Copy Markdown
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.8.1:

1
5188350___-1024x1024.jpg

V7.9Beta:

1.webp
5188350___-1024x1024.jpg

Notice the .webp added to first image in 7.9

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants