Force WebP

Descripció

This plugin converts every uploaded JPG or PNG image into modern WebP format to improve performance and reduce file size.

Key features:
– automatic conversion of JPG and PNG images to WebP on upload
– thumbnails are written directly as WebP by WordPress itself – one lossy pass instead of two
– configurable WebP quality level
– optional maximum image width (original images are resized before thumbnails are generated)
– optional removal of the original JPG/PNG files to save disk space
– ICC colour profiles are preserved, so photos keep their colours
– self-healing metadata: broken thumbnail references are corrected automatically
– built-in repair tool for media libraries damaged by older versions
– automatic alt text generation based on the filename
– filename sanitization and collision-safe renaming

All settings apply only to newly uploaded images. Existing media files are not modified.

Configuration

You can configure the plugin in Tools Force WebP.

Available options:
– WebP quality (0-100): controls compression quality for newly uploaded images
– Max width (px, optional): limits the maximum width of original images before WordPress generates thumbnails (0 = disabled)
– Keep original JPG/PNG: keeps the source file after a successful conversion (off by default)

The same page offers a repair tool that fixes attachments whose thumbnails were broken by versions 1.2-1.5 (see FAQ).

All settings affect only images uploaded after saving the configuration.

Instal·lació

Requirements:
* Imagick with WebP support
* PHP 7.4 or newer

How to install:
1. Download the plugin or install it from the WordPress Plugin Directory.
2. Activate it via the Plugins menu in WordPress.
3. From now on, any JPG or PNG file uploaded to the Media Library will:
– be converted to WebP
– have the original file removed (unless “Keep original JPG/PNG” is enabled)
– receive an alt text based on the filename
– be renamed to avoid overwriting if duplicates exist

PMF

My thumbnails are broken: the full image opens, but the grid shows a placeholder. What happened?

Versions 1.2-1.5 could store thumbnail filenames ending in .jpg or .png while the files on disk were already converted to WebP. This happened when another plugin re-saved the attachment metadata during the upload – most visibly when uploading through the media modal of a page builder. Version 1.6 fixes the cause and ships a repair tool in Tools Force WebP that rewrites the stored filenames to match the files on disk. It does not create or delete any file.

Does the plugin modify existing media?

No. Conversion affects only newly uploaded images. The repair tool only corrects wrong filenames in the database.

Should I enable “Keep original JPG/PNG”?

It is off by default, which is what most people install this plugin for. Bear in mind that with originals deleted, a WebP file is the only copy of the image: if a thumbnail is ever lost there is nothing to regenerate it from. If disk space is not a concern, keeping the originals gives you a fallback. Either way, keep backups.

Does the plugin support GIFs?

No. Only JPG/JPEG and PNG are supported. Other formats remain unchanged.

What happens if the server does not have Imagick with WebP support?

The plugin deactivates itself and displays an admin notice “Please enable Imagick with WebP support on your server”.

How can I change the compression quality?

The default is 95%. You can change it in Tools Force WebP. The new quality will be applied to all images uploaded after you update the setting.

Does the plugin generate WordPress thumbnails correctly?

Yes. Since 1.6 WordPress writes the intermediate sizes as WebP itself (via the image_editor_output_format filter), so thumbnails are encoded only once and their filenames can never disagree with the metadata.

Can I go back to the old conversion path?

Yes:
add_filter( ‘force_webp_use_core_output_format’, ‘__return_false’ );
WordPress will then create JPG/PNG thumbnails and the plugin will convert them afterwards, as in 1.5.

Is it compatible with WordPress 7.1 client-side media processing?

Yes. Conversion runs on wp_generate_attachment_metadata, which fires whether the image sizes were created in the browser or on the server, so images are still converted to WebP. On top of that, the self-healing metadata check (added in 1.6) reconciles the stored filenames with the files on disk regardless of which upload path created them, so browser-side processing does not leave broken thumbnails.

What happens to very large images?

If a maximum width is configured, large images are automatically resized before thumbnails are generated. WordPress backup originals are removed to avoid duplicate files, unless “Keep original JPG/PNG” is enabled.

Ressenyes

21 de novembre de 2025 1 reply
The plugin is great — the images are really converted to WebP and the original files are deleted as expected. Congratulations to the developer. But I noticed two bugs: it seems to interfere with the generation of the site’s thumbnails, so the entire site ends up loading the full-size image only. Also, the quality level setting doesn’t work. I tested it by setting it to 10 and then to 90, and the output stayed the same. Another idea would be to add a maximum width limiter for images. For example, when I upload an image, I want it to be converted to WebP and also resized to a maximum width of 1000px (of course, this value should be configurable). It would be great to have this feature.
Llegir tota la 1 ressenya

Col·laboradors i desenvolupadors

«Force WebP» és programari de codi obert. La següent gent ha col·laborat en este complement.

Col·laboradors

Traduïx «Force WebP» a la teua llengua.

T’interessa el desenvolupament?

Revisa el codi , dona una ullada al repositori SVN o subscriu-te al registre de desenvolupament per RSS.

Registre de canvis

1.6

  • Tested up to WordPress 7.1, including the new client-side media processing path.
  • Fixed: attachment metadata could keep pre-conversion .jpg/.png filenames while the files on disk were WebP, breaking thumbnails (most often when uploading through a page builder’s media modal). The metadata filter now runs at priority 20 instead of 5, and the mime type is updated without firing post-save hooks in the middle of metadata generation.
  • Fixed: on the WordPress 7.1 upload path (and with client-side media processing) core writes the full-size file as WebP directly; the plugin previously returned early, leaving the attachment recorded as image/jpeg with the source file still on disk. It now detects an already-WebP original and finishes the job (mime type + cleanup) without re-encoding.
  • Added: self-healing metadata. Any save of a WebP attachment’s metadata is checked against the filesystem and corrected, whichever plugin triggered it.
  • Added: repair tool in Tools Force WebP for media libraries already affected by these bugs. It fixes both filename mismatches and WebP files still recorded as image/jpeg or image/png. No file is created or deleted.
  • Added: “Keep original JPG/PNG” option for sites that want a fallback copy of every image.
  • Improved: WordPress now writes intermediate sizes directly as WebP (image_editor_output_format), so thumbnails are encoded once instead of being generated as JPG and re-encoded. Faster uploads, better quality, lower memory usage. Revert with the force_webp_use_core_output_format filter.
  • Improved: ICC colour profiles are preserved during conversion. Photos in Adobe RGB or Display P3 no longer lose their colours.
  • Removed: the extra Imagick resize of the original before thumbnail generation. WordPress big-image scaling already honours the max-width setting, and the extra pass meant an additional lossy re-encode.

1.5

  • Fixed an issue where some WordPress thumbnail sizes could be skipped during WebP conversion.
  • Improved metadata handling for duplicate thumbnail files.
  • Improved stability of thumbnail conversion.

1.4

  • Tested compatibility with WordPress 7.0
  • Lowered minimum PHP requirement to 7.4
  • Added safer filename handling
  • Added fallback support for missing mbstring/iconv extensions
  • Improved plugin compatibility checks
  • Improved documentation

1.3

  • Improved compatibility with other plugins by lowering upload hook priorities.
  • Other plugins can now safely set or override image title and alt text.
  • Minor internal code and stability improvements.

1.2

  • Fixed thumbnail generation issue (conversion now runs after metadata creation) – thanks to @koultti.
  • Added optional maximum image width setting for original uploads.
  • Integrated with WordPress big image scaling.
  • Automatic removal of WordPress backup original images.
  • Improved WebP quality handling (quality setting now reliably affects output).
  • Internal code cleanup and stability improvements.

1.1.4

  • Added a “Settings” link on the plugins list.
  • Added server WebP support status message on the settings page.

1.1.3

  • Typo fixed.

1.1.2

  • Changed minimum required PHP version to 8.1.
  • Changed minimum WordPress version to 6.5.

1.1.1

  • Improvements and small fixes.

1.1

  • Improved: plugin now checks whether Imagick is available on the server.

1.0.3

  • Fixed issue where PNG images without transparency were converted to fully transparent images.
  • Added configuration page in Tools Force WebP to set image quality.

1.0.2

  • Default WebP changed to 90%.

1.0.1

  • Added filename uniqueness handling for WebP files.

1.0

  • Initial release: convert JPG/PNG to WebP (90% quality), remove original files, rename files, and set alt text.