I am developing a WordPress plugin that optimizes the website. Currently, I am trying to convert all the images (PNG, JPG and JPEG) images to Webp using Rosell-dk's webp library https://github.com/rosell-dk/webp-on-demand which supports sending the image links via .htaccess as a GET request. But unfortunately it doesn't work, I am not sure if I am doing it wrong or if my approach is completely wrong.
I tried writing the rules that were stated by Rosell-dk on the GitHub page https://github.com/rosell-dk/webp-on-demand but unfortunately they doesn't work. The following is the rules that I have pasted on the .htaccess file which I created in my WordPress installation's 'wp-content' folder as all the images for a WordPress website resides there.
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect images to webp-on-demand.php (if browser supports webp)
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteRule ^(.*)\.(jpe?g|png)$ /plugins/*my plugin name*/inc/webp-converter/webp-on-demand.php?source=%{SCRIPT_FILENAME} [NC,L]
</IfModule>
And in my 'webp-on-demand.php' I have the following
$imageSource = $_GET['source'];
Unfortunately the file 'webp-on-demand.php' doesn't get called at all.
It would be great if y'all could help me figure out the correct rules or where I am wrong.