(Help) Automatic png, jpg to webp conversion on wordpress

#1
Hello, I'm writing here after many searches and unsuccessful attempts to set up automatic conversion of jpg, png images to webp when the browser supports it on my wordpress.

I've converted my images to webp with the WebP Express extension, but I can't activate automatic conversion of images to webp (image.png.webp or image.jpg.webp).

I've tried using the rewrite rules in .htaccess but it doesn't work, I've also tried adding two static context for image rewriting but nothing either ((https://forum.openlitespeed.org/thr...t-still-execute-document-level-rewrites.5160/).

I'm using WP Rocket as my cache extension, so I can't use LiteSpeed Cache.
My server runs on OpenLiteSpeed 1.7.19 in multi-domain.

Thanks in advance for your help.
config-webp-express.png context-static-1.png context-static-2.png
 

Cold-Egg

Administrator
#2
Does it work if you visit the png and webp images directly from the browser? If so, a general rewriterule should work.

I'm not pretty sure how the WebP Express extension handles the serving webp to the browser, you might want to contact them with more information.
 
#3
Hello, thank you for your reply.

When you ask if it works directly from the browser, you say to add .webp to the extension in the url? If yes, then yes it works.

Webp Express can handle the conversion in several different ways, but they recommend it as configured. Then, they use redirection rules with .htaccess but I have the impression that these rules are ignored...

I just saw that I had another error message:

"It seems your server setup does not support headers in .htaccess. You should either fix this (install mod_headers) or deactivate the "Enable direct redirection to existing converted images?" option. Otherwise the Vary:Accept header will not be added and this can result in problems for users behind proxy servers (ie used in larger companies)"

And while looking for this error, I saw that OpenLiteSpeed doesn't support rewrite rules in .htaccess, do you have a solution?
 
Last edited:

LiteCache

Active Member
#5
@SeikoSEO

This is not a rewrite issue with OLS. Check the rewrite rules added by WebP Express. It redirects to a PHP file to convert jpg|png to webp, but if a page is cached there is no PHP.
 
#6
Hello, thank you for your answers.

@Cold-Egg
Yes, I've enabled rewriting and autoload of .htaccess.

If I've understood correctly, Vary:accept is used to check whether the user's browser supports the webp extension.

Here are the contents of the .htaccess file
https://pastebin.com/QDN2qtHm

@LiteCache
I've disabled redirection to convert the image, I've converted all the images beforehand.

Thank you in advance.
 
Last edited:
#7
Hello again,

well, I've just found the solution by chance^^.

Maybe it will help some of you:

I use WP Rocket as a cache extension and they have a "WebP Compatibility" option that was disabled. So I activated it and now I have WebP images.

It's really weird because WP Rocket advises against enabling this option if our WebP plugin is serving webp images (which is the case for me).
 
Top