WP Image Compress To WebP
WordPress plugin that automatically converts newly uploaded JPG, JPEG, and PNG images into WebP format at quality 80, then removes the original source files.
by ksnfjsbd-a11y · github.com/trangpcvn/wp-image-compress-to-webp · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/trangpcvn/wp-image-compress-to-webp/archive/refs/heads/main.zipWordPress plugin that automatically converts newly uploaded JPG, JPEG, and PNG images into WebP format at quality 80, then removes the original source files.
Overview
This plugin hooks into the WordPress media upload pipeline and:
- Converts original uploaded images to WebP
- Converts generated intermediate sizes (thumbnails, medium, large, etc.) to WebP
- Deletes the original non-WebP files after successful conversion
- Updates attachment metadata so generated sizes point to WebP files
It also includes a lightweight admin dashboard for local license key management.
Features
- Automatic conversion of newly uploaded
jpg,jpeg, andpngfiles - WebP quality fixed at
80(current implementation) - Original and intermediate files are removed only after successful WebP generation
- Uses
Imagickwhen available, with fallback toGD(imagewebp) - Admin page under WebP Compress for license activation/deactivation
- Dashboard button to convert existing JPEG/PNG media to WebP with progress
- Dashboard button to regenerate thumbnails for all image attachments with progress
- Nonce-protected license form handling and capability checks (
manage_options)
Requirements
- WordPress (plugin-based installation)
- PHP with at least one of:
Imagickextension, orGDextension with WebP support (imagewebp)
Without these capabilities, image conversion will fail and original uploads will remain unchanged.
Installation
- Copy
wp-image-compress-to-webpintowp-content/plugins/. - In WordPress admin, go to Plugins and activate WP Image Compress To WebP.
- Open WebP Compress in the admin menu to review dashboard and license status.
- Upload images through Media Library as usual.
Usage
Automatic conversion flow
After activation, no additional setup is required for conversion:
- Upload a supported image (
jpg,jpeg,png). - Plugin attempts to generate a
.webpversion at quality 80. - On success, the original uploaded file is deleted.
- Generated image sizes are also converted to WebP and updated in metadata.
License dashboard
Go to WebP Compress in WP Admin:
- Enter a license key and click Save & Activate License
- Click Deactivate License to clear stored key and status
Note: Current license activation is local format validation only (no external API validation).
Convert existing media
Go to WebP Compress in WP Admin and click Convert Old Images to WebP.
- The dashboard shows conversion progress for old JPEG/PNG attachments.
- Existing items are processed in batches to avoid request timeouts.
Regenerate all thumbnails
Go to WebP Compress in WP Admin and click Regenerate All Thumbnails.
- The dashboard shows regeneration progress for image attachments.
- Items are processed in batches to avoid request timeouts.
Current behavior and limitations
- New uploads are converted automatically; existing media can be converted manually from the dashboard.
- Only
jpg,jpeg, andpngare handled. - Conversion quality defaults to 80 and can be adjusted via the
wicw_webp_qualityfilter. - No remote license server check is implemented yet.
Project structure
wp-image-compress-to-webp.php— Plugin bootstrap and module loadingsrc/image-converter.php— Upload and intermediate size conversion logicsrc/license.php— License key storage and local validationsrc/admin.php— Admin menu, dashboard rendering, and asset loadingassets/admin-dashboard.css— Dashboard styling
Security notes
- Direct file access is blocked with
ABSPATHchecks. - License actions require admin capability checks.
- Form submissions are protected using WordPress nonces.
- User-provided license input is sanitized before storage.
Version
Current plugin version: 1.0.0