This PHP script combined with the directives in the corresponding .htaccess files automatically converts all .jpg, .jpeg and .png files to WebP and serves those instead if the browser supports it.
Copy all files from the src folder into the /wp-content/uploads/ folder of your WordPress installation. If you want to use the code with any other CMS or even without a CMS, copy the files to the root directory of your content path. If you're not using WordPress, make sure to change the RewriteBase in the .htaccess file to your path.
The PHP extension Imagick has to be installed on the Webserver.
If you have any questions or comments, feel free to contact me through the email address provided in the project files. Additionally, feel free to check out my blogs and YouTube channel for additional information, examples and feedback:
Blog (EN): https://baltic-lab.com
Blog (DE): https://baltic-labor.de/
YouTube (EN): https://www.youtube.com/c/BalticLab
- v0.0.1 Initial release