WP Manifestindependent plugin directory
manifest / performance / wp-mu-webp

nitida — WebP Media

WordPress must-use plugin: converts JPEG/PNG uploads to WebP in place via Imagick, archives originals, and adds `wp webp` bulk commands.

by nitida · github.com/lintmycode/wp-mu-webp

★ 0stars
0forks

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/lintmycode/wp-mu-webp/archive/refs/heads/main.zip

nitida/wp-mu-webp

WordPress must-use plugin, installed with Composer, that makes a site serve WebP only. Every JPEG/PNG upload (full size, every sub-size, original_image) is converted to WebP right after WordPress generates the sizes, and the attachment's file, metadata and mime type are updated. Originals move to uploads/originals/<same path>; nothing references them afterwards.

Requires the Imagick PHP extension. GD is never used for the WebP save: it throws an uncatchable fatal on palette PNGs. Without Imagick, uploads are left as they are.

Animated GIFs are left alone (a WebP re-encode keeps only the first frame).

Install (Bedrock)

composer config repositories.wp-mu-webp vcs https://github.com/lintmycode/wp-mu-webp.git
composer require nitida/wp-mu-webp:^1.0

composer/installers puts it in web/app/mu-plugins/wp-mu-webp/. Make sure that directory is ignored, and delete the hand-copied webp-media.php and webp-media/ folder in the same commit. Both would hook the same upload.

Existing media

wp webp convert --dry-run            # list what would convert
wp webp convert [--batch-size=50]    # convert the library in place
wp webp regenerate_size <size> [--dry-run] [--force]   # use instead of `wp media regenerate`

Use wp webp regenerate_size, not wp media regenerate: core's command picks GD and can hit the same uncatchable fatal partway through a library.

URLs stored as plain strings (CMB2 file fields, page-builder JSON, term meta) still point at the old .jpg/.png after conversion. Check a site for those before converting its library.

Filters

Filter Default Use
webp_media_skip_conversion false, $attachment_id keep one attachment as JPEG/PNG, e.g. the og:image (Facebook/LinkedIn don't take WebP)
webp_media_upload_time_limit 300 seconds an image upload may take; sites that cap max_execution_time low need this