Ignore larger WebP images
-
Hi there!
Currently, if you enable the WebP creation the WebP version is added to the frontend no matter what. This is a problem for us since some WebP images are by far larger than their original counterpart.
Example:
WebP 888,9 KiB: https://www.stroeer-direkt.de/wp-content/uploads/sites/7308/2021/11/Hannover_CLP_Fussgaengerzone-1920×1280-1-1536×1024.jpg.webp
Original 392,6 KiB: https://www.stroeer-direkt.de/wp-content/uploads/sites/7308/2021/11/Hannover_CLP_Fussgaengerzone-1920×1280-1-1536×1024.jpgThere is no fine-grained mechanic to change this.
I see two solutions here:
1. ShortPixel handles this while creating the
srcset
attribute and compares the file sizes (plus for checking against the attachment metadata since the sizes are already there). This would also require to change the code from a single<source>
with a largesrcset
to multiple<source>
elements for each size since otherwise missing sizes are just replaced by the next lower source from the samesrcset
.2. Allow filtering the
srcset
along with the attachment ID so that I can do the comparison by myself.I already tried to use a wrapper output buffer, but it’s more of guessing than a proper way to fix this.
Best regards,
Matthias
- The topic ‘Ignore larger WebP images’ is closed to new replies.