Opens in a new tab

WordPress hosting from €0.60 a month the first year. See the plans

Beltoft WebP

Creates a WebP and an AVIF copy of each JPEG and PNG upload, thumbnails included, for nginx to send to browsers that accept them.

Requires WordPress 6.2+ and PHP 8.0+. Free. A free license key turns on automatic updates.

Beltoft WebP settings screen

How it works

1

Install the plugin

Activate it. The settings are under Settings > Beltoft WebP, and the defaults work without changes.

2

Convert existing images

Run wp beltoft-webp backfill once. New uploads are converted automatically from then on.

3

Add the nginx rules

Add the rules from the readme to your server block. nginx sends the AVIF file to browsers that accept it, then WebP, then the original.

Features

Background conversion

Uploads are converted in a background job by Action Scheduler or WP-Cron. The original is served until the job has run.

Backfill command

Converts the existing media library and reports converted, current, not smaller and failed files and the space saved. --dry-run shows what would happen.

Quality

WebP quality 85 and AVIF quality 70 by default. Each format can be turned off. backfill --force rebuilds the files after a change.

Only smaller files

A copy that is not smaller than the original is deleted, and so is an AVIF that is not smaller than the WebP.

Transparent PNG

Transparent product photos become lossy WebP with the transparency kept. Logos and icons with few colours stay lossless.

File handling

Copies are written to a temporary file first, keep the original's permissions and are removed with the image.

Theme and HTML

The plugin does not change your HTML or your theme.

Hooks

Actions run after a file is converted, after a backfill and when a conversion fails.

File size by format

One 1448 x 1086 photo, converted with the default settings.

photo.jpg

306 KB

photo.jpg.webp

178 KB

photo.jpg.avif

143 KB

On one site, backfill reduced 350 files from 41 MB to 18.8 MB.

Frequently asked questions

Only after the nginx rules are in place. Until then, browsers get the original files.

PHP Imagick with AVIF support. WebP uses GD.

Files named photo.jpg.webp are used. Files named photo.webp are not.

The settings are removed. The .webp and .avif files stay.

It turns on update notices. Activating it sends the key and the site domain to beltoft.net.

Install Beltoft WebP

The plugin works without a license key. Get a free key for automatic updates, or read the code first.