Description
JBWEBDEV Image Format Converter is a WordPress plugin that automatically converts your media library images to WebP and AVIF formats using configurable lossy compression quality (with optional lossless WebP encoding for PNGs), reducing file sizes while keeping original files intact.
Key Features
- Automatic conversion on upload — Every JPEG, PNG, GIF, and BMP you upload is queued for WebP conversion and, when AVIF is enabled and supported by your server’s image library, AVIF conversion.
- Optional AVIF — AVIF output is off by default. Switch it on under Tools Format Converter once your server supports it (PHP 8.1+ with GD 2.3.2+, or ImageMagick with libheif).
- Bulk conversion — Convert your entire media library in background batches with a real-time progress bar.
- Smart serving — Serves
.webp/.aviffiles only to browsers that support them (preferring AVIF when both exist); all other browsers receive originals. - Apache & Nginx support — Generates ready-to-paste server config for zero-PHP-overhead image serving.
- Original preservation — Keeps original files by default and optionally backs them up to a configurable sub-folder.
- Quality control — Set your preferred lossy compression quality for WebP (1–100, default 82) and AVIF (1–100, default 60, opt-in), or switch PNGs to lossless WebP encoding.
- Per-format control — Opt individual formats (JPEG/PNG/GIF/BMP) out of conversion entirely.
- Size safety net — Automatically discards a converted WebP/AVIF file and keeps the original if conversion didn’t actually shrink it.
- Orphan cleanup — Removes generated WebP/AVIF and backup files when the original attachment is deleted.
- CDN-aware rewriting — Optional CDN base URL so HTML rewriting still matches CDN-served image URLs.
- Zero dependencies — Uses WordPress’s own image libraries (GD/Imagick). No Composer required.
Configuration & Usage
- Open Tools Format Converter. Out of the box, auto-convert on upload, original preservation, and HTML URL rewriting (via WordPress 6.9+’s template enhancement buffer with
Vary: Accept) are enabled with WebP quality82. - Adjust lossy quality, enable Lossless PNG Encoding, toggle AVIF (default quality
60), or opt out specific source formats in the settings form, then click Save Settings. - Click Start Bulk Conversion to convert existing library images in batches (you can click Stop at any time).
- (Optional) In the Server Configuration panel, use the Apache / .htaccess or Nginx tabs to apply or copy server-level serving rules.
Installation
- Upload the
jbwebdev-image-format-converterfolder to/wp-content/plugins/. - Activate the plugin via Plugins Installed Plugins.
- Navigate to Tools Format Converter to review settings and run a bulk conversion on existing images.
- (Optional) Use the Server Configuration panel to apply
.htaccessrules or copy the Nginx snippet for server-level WebP/AVIF serving.
FAQ
-
Does this plugin delete my original images?
-
No. By default, originals are preserved alongside the
.webp/.aviffiles. You can also enable backup copies in a dedicated sub-folder. -
What happens if my server doesn’t support WebP?
-
The plugin detects WebP support at boot. If neither GD (with WebP) nor Imagick (with WebP) is available, an admin notice is shown and conversion is gracefully disabled.
-
Is the conversion lossless?
-
Not by default. WebP (default quality 82) and AVIF (default quality 60) use lossy compression, which makes files much smaller with little visible change at the default settings. Lower the quality for smaller files, or raise it to keep more detail. PNGs can be converted to lossless WebP with the Lossless PNG setting.
-
Will this break images for users on old browsers?
-
No. The URL rewriter checks the browser’s
Acceptheader and only serves.avif/.webpto browsers that declare support. All others receive the original file. -
Can I stop a bulk conversion mid-run?
-
Yes. Click the Stop button on the settings page. The current batch will finish and then the process will halt cleanly.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“JBWEBDEV Image Format Converter” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “JBWEBDEV Image Format Converter” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
1.0.13
- Changed HTML rewriting to use WordPress’s template enhancement output buffer (WordPress 6.9+) instead of opening its own output buffer. The plugin now requires WordPress 6.9.
- Added a
Vary: Acceptheader to pages the HTML rewriter handles, so shared page caches don’t serve WebP/AVIF image URLs to browsers that can’t show them. - Improved srcset size lookup to scan each uploads folder once instead of once per image.
- Reduced admin notices: version and missing-WebP notices show only on the Plugins screen, the missing-AVIF notice only there and on the plugin’s settings page, and none on the Dashboard. Fixed the settings page showing the missing-WebP warning twice.
- Updated the readme and plugin description: conversion is lossy at a quality you choose (no “without losing quality” claim), AVIF is off by default, and the AVIF quality setting is documented.
1.0.12
- Fixed the “space saved” statistic double-counting images that have both a WebP and an AVIF file — each image now counts only its best variant. Existing cached values are recalculated automatically after updating.
- Fixed Bulk Convert never generating AVIF for images converted before AVIF was enabled — turning AVIF on now backfills the existing library (for formats that are switched on), and each image is only attempted once.
- Fixed the bulk conversion summary always reporting 0 skipped images (skipped images were counted as converted).
- Fixed images of a format switched off in settings counting as “pending” forever and being retried on every bulk run. The pending count now always matches what Bulk Convert will process, and Total only counts formats that are switched on. While AVIF is catching up, Pending also includes converted images that have not been tried for AVIF yet.
- Fixed backup copies of originals being left behind when a conversion failed or the WebP was discarded for not being smaller — a backup is now made only when the WebP is kept.
- Fixed a PHP 8.5 deprecation notice (
imagedestroy()) during GD conversion. - Switched HTML rewriting from a manual
ob_start()call to WordPress 6.9’s core template enhancement output buffer (wp_template_enhancement_output_buffer) and raised the minimum WordPress version to 6.9. - Added
Vary: Acceptheader emission (viawp_headers) for PHP-rewritten HTML responses so shared caches serve format-compatible markup per browser. - Indexed sized
srcsetsiblings with a single streamingopendir()/readdir()pass per uploads directory instead of rescanning the directory for each distinct image basename. - Internal: merged the duplicated WebP/AVIF conversion code into one pipeline, shared settings field renderers, and removed dead code (unused
_webpavop_webp_pathpost meta, legacy lock transient fallbacks).
1.0.11
- Fixed Nginx configuration generation to define separate AVIF and WebP fallbacks (
try_files $1$avif_suffix $1$webp_suffix $uri) so Nginx falls back to WebP when AVIF is missing before falling back to the original file. - Fixed HTML rewriter
srcsetcandidate parser to correctly handle URLs with embedded commas (e.g. query parameters). - Fixed HTML rewriter updating
<source>typeattribute when substituting modern format image sources in<picture>elements. - Fixed HTML rewriter incorrectly rewriting image links inside anchor
<a href="...">tags. - Fixed HTML rewriter to bail on XML payloads (e.g. sitemaps), treat
Acceptheaders withq=0as unsupported, and skip output buffering on sitemap URIs. - Fixed bulk conversion concurrency by separating the active batch mutex lock (
webpavop_bulk_inflight) from the persistent running heartbeat (webpavop_bulk_running) to prevent race conditions during Stop/Reset operations. - Hardened backup folder setting sanitization to reject path traversal and directory separators/dots.
- Hardened plugin uninstaller to remove
_webpavop_size_savedpostmeta, clear scheduled cron hooks, and delete all plugin transients on single-site and multisite installations.
1.0.10
- Renamed the plugin again, from “WebP & AVIF Optimizer” to “JB Webdev Image Format Converter” (slug/text domain:
jbwebdev-image-format-converter) — the WordPress.org review team flagged the format-first name as too generic and asked for a distinctive, brand-first name. - Renamed all internal code identifiers — PHP namespace,
WPWO_/wpwo_constant and function prefixes, option/transient keys, post meta keys, AJAX actions, and enqueue handles — to the reviewer-suggestedWEBPAVOP_/webpavop_prefix family for stronger namespace uniqueness (Plugin Directory guideline on overly generic global-namespace prefixes). - Fixed a readme inconsistency where the short description and several sections mentioned only WebP despite the plugin also converting to AVIF.
- Fixed the “Start Bulk Conversion” button staying visible after a bulk conversion finished with zero images remaining — it now only reappears when images are still pending.
- Fixed the readme.txt Upgrade Notice for 1.0.9 exceeding the 300-character limit enforced by Plugin Check.
- Fixed
.distignoreleaving an emptydocs/folder in the built plugin zip — excluded the whole directory instead of individual file patterns.
1.0.9
- Fixed admin notices from other plugins (e.g. license nags) being relocated into the middle of this plugin’s settings-page header instead of appearing above it.
- Fixed WebP/AVIF conversion silently failing on palette/indexed-color source images (8-bit “PNG-8” logos, all GIFs) — the GD fallback now promotes the image to truecolor before encoding, and a 0-byte “success” from the WordPress image editor no longer blocks that fallback from running.
- Added debug logging (gated behind
WP_DEBUG_LOG) for conversion failures, including the underlying GD/Imagick encoder error, to make troubleshooting failed conversions easier. - Scoped the PHP/WP version, WebP support, and AVIF support admin notices to the plugin’s own settings screen, the Plugins list, and the Dashboard instead of every wp-admin page (Plugin Directory guideline: notices must be limited in scope).
- Updated Tested up to WordPress 7.0.
- Renamed the plugin from “WP WebP Optimizer” to “WebP & AVIF Optimizer” (slug/text domain:
webp-avif-optimizer) — Plugin Check flagged “wp” as a restricted trademarked term in the plugin name and slug. - Fixed all Plugin Check errors: missing translators comments on placeholder strings, unescaped output in three numeric settings fields,
is_writable()replaced withwp_is_writable(), and documented the two intentionally-safe dynamic-placeholder$wpdb->prepare()IN-clause queries and the chunked-read animated-GIF detector that Plugin Check cannot statically verify. - Fixed all Plugin Check global-variable-prefix warnings in
admin/views/settings-page.phpanduninstall.phpby prefixing local variables withwpwo_. - Removed the discouraged
load_plugin_textdomain()call — WordPress.org auto-loads translations for hosted plugins since 4.6.
1.0.8
- Fixed malformed
srcsethandling in the PHP HTML rewriter for builder-generated markup (including Spectra/UAGB patterns) so every candidate is processed, not only the first entry. - Fixed missing width descriptor recovery by deriving
Nwfrom-WxHfilename suffixes when asrcsetcandidate is emitted without a descriptor. - Fixed oversized responsive candidate selection by remapping full-size URLs paired with small
wdescriptors to the closest on-disk intermediate size before AVIF/WebP substitution. - Fixed Lighthouse oversized-image regressions by dropping marginally larger full-size candidates and capping
<img>srcsetwcandidates above each tag’s declaredwidth. - Added targeted regression tests covering multi-entry
srcsetrewrites, descriptor injection, variant remapping, and width-cap filtering.
1.0.7
- Added AVIF encoder support — every conversion now also produces an AVIF sibling when the host can encode AVIF, with cleanup and rewriting kept in sync.
- Added
wp_ajax_wpwo_bulk_resetadmin action so a stuck bulk run can be cleared without database surgery; the running flag now refreshes on every batch as a heartbeat. - Added zero-byte encoder guard — empty WebP/AVIF outputs are deleted and surfaced as a conversion error instead of being recorded as success.
- Added rewriter guards for sitemaps and non-
text/htmlresponses so cached XML/JSON/feed payloads are never rewritten. - Added
.distignoreso release builds ship only runtime files and bundled assets. - Hardened
wpwo_get_avif_stats()to reuse the cached conversion-stats query instead of running its own duplicate JOIN. - Hardened MIME-type DB queries to parameterise the IN-clause through
$wpdb->prepare()instead of inlining strings. - Hardened uninstall to also remove
_wpwo_avif_pathpost meta (single-site and multisite). - Hardened the .htaccess admin notice rendering with
wp_kses_post()instead of unescaped echo. - Fixed cron handler to document the metadata-fallback contract so
wp_get_attachment_metadata()is only consulted after core commits.
1.0.6
- Added lossless PNG encoding option to preserve high-fidelity PNG sources during WebP conversion.
- Added option to skip WebP serving/generation if the resulting WebP file is larger than the original image.
- Added cleanup-on-delete option to automatically remove generated WebP files and backups when an attachment is deleted.
- Added CDN base URL support to rewriting logic for offloaded media libraries.
- Added per-format opt-out settings (JPEG, PNG, GIF, BMP) to disable WebP conversion for specific formats.
- Added configurable bulk batch size setting via the admin UI.
- Fixed unique WebP basename check to use glob() to avoid collisions with case-insensitive file extensions.
1.0.5
- Added collision prevention for WebP targets during upload (e.g., logo.jpg and logo.png will now safely generate unique WebP files).
- Refactored core conversion and rewrite logic into dedicated service classes.
1.0.4
- Refactored MIME type handling to adhere to DRY principles.
- Fixed HTML rewriter regex to use the single source of truth for WebP path generation.
- Removed unused imports in admin classes.
1.0.3
- Moved settings page from Settings menu to Tools menu.
- Added Settings link to plugin action links.
- Added PHP 8.0 and WordPress 6.0 startup requirement checks with admin notices.
- Fixed critical path traversal vulnerability in uploads directory validation.
- Fixed HTML rewrite regex failing on image URLs containing query parameters.
- Fixed Nginx config missing
add_headerglobal inheritance warning. - Fixed Apache CDN caching bug —
Vary: Acceptnow applied unconditionally for image paths. - Fixed animated GIFs losing animation (animated GIFs are now skipped during conversion).
- Fixed double slash in WebP URL when images are in the root upload directory.
- Fixed multisite uninstaller transient leak.
- Removed redundant database writes during bulk conversion batches.
- Fixed uninstall not removing
_wpwo_convertedand_wpwo_webp_pathpost meta. - Fixed “Copied!” label not being translatable.
- Fixed
Vary: Acceptheader string-variable indirection in htaccess writer. - Optimised conversion stats with a 30-second transient cache.
1.0.2
- Fixed browser compatibility regression by keeping original attachment paths/mime canonical (no primary promotion to WebP).
- Fixed upload conversion timing by converting against in-memory attachment metadata generated in the same request.
- Improved bulk/settings UI button layout consistency in the admin screen.
1.0.1
- Fixed Nginx snippet to use
$uri$webp_suffixand$urifallback for valid path resolution. - Fixed Apache rewrite target to
$1.$2.webpand madeVary: Acceptemission explicit via env flag. - Hardened PHP HTML rewrite gating to skip feeds, trackbacks, robots, and embeds.
1.0.0
- Initial release.
