Standalone image webp converter and provider WordPress plugin
wp-cubi-image-webp is a very simple image converter and provider plugin for WordPress, meant to be used in a composer installation. It uses php gd extension to convert uploaded images into webp images (jpg and png).
The PHP gd extension must be activated to convert images to webp
composer require globalis/wp-cubi-image-webp
Insert this chunk of code into your .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME}.webp -f
RewriteRule (.+)\.(jpg|jpeg|png)$ $1.$2.webp [T=image/webp,NC,L]
</IfModule>Define WP_CUBI_IMAGE_WEBP_REWRITE_URL to true in your functions.php
Bulk image optimization can be done using wp-cli :
- Install wp-cli and ensure wp-cubi-image-webp is activated
- Usage:
wp webp generate <directories>... [--force=<false|true>] - Help:
wp help webp generate
