Page 1 of 1

webp_image returning original source files

Posted: Mon Feb 24, 2025 1:54 pm
by smithdesign77
Hi!

While setting up a new gallery thingy (changes on caption and stuff), I also tried to implement WebP-images … but: It didn't work.
First I thought the path settings may have changed and manually fed an url to an image … didn't work either.

In search for a solution I stumbled upon this discussion: viewtopic.php?p=350197&hilit=webp_image#p350197
However, in my case I just simply call the very regular gallery url, which is like ...blabla.com/gallery/tag/38.html just how the gallery module generated it - no fancy JS, no delayed loading, no tweaks in the gallery module or whatsoever else I'd know of.
However, that "( $_SERVER[ 'HTTP_ACCEPT' ], 'image/webp' ) !== false)" from that discussion I just mentioned stuck with me. ???
So I copied that php-file and started commenting out all those conditions (lines 55, 75, 79, 81, 82, 83) — and NOW the magic happened! ;D

But now I'm just puzzled why - and I very much dislike the fact that there's no fallback, altho meanwhile every browser should accept WebP?
Still, not a good thing. But: WHY is this?
And I very much remember, that this very plugin HAD worked with an other page - and I just checked it and it also now serves only the original jpg-source files (all the webp-files are still in the tmp/cache/ folder tho).
So, something must've happened since whatever the latest CMSms releases or PHP update (I'm on 8.1).

Do you have any ideas?
Thanks!

Re: webp_image returning original source files

Posted: Tue Feb 25, 2025 9:46 am
by creopard
It could be possible that the original solution also required editing the .htaccess file like this: https://github.com/vincentorback/WebP-i ... h-htaccess

But nowadays all those checks are obsolete as all current web browsers support "webp" images, see https://caniuse.com/?search=webp
No fallback option needed, unless you still want to support Internet Explorer ;D

Re: webp_image returning original source files

Posted: Thu Feb 27, 2025 3:59 pm
by smithdesign77
Huh. Good point.
Well, then I'd propose updating the repository; I attached the updated file here for someone who has authority to add it. The only changes made were those I mentioned in my first post: deleting the lines 55, 75, 79, 81, 82 and 83 and adding the change info in the about-text, but without taking any credit. The code is still completely Yuris.
Thank you!

Re: webp_image returning original source files

Posted: Fri Feb 28, 2025 8:22 am
by creopard
You could also file a pull request to the original author, see:
https://github.com/wdwp/webp_image (via http://dev.cmsmadesimple.org/project/code/1480)