| 开发者 | kitgenix |
|---|---|
| 更新时间 | 2026年10月30日 18:47 |
| 捐献地址: | 去捐款 |
| PHP版本: | 8.2 及以上 |
| WordPress版本: | 7.4 |
| 版权: | GPLv3 or later |
| 版权网址: | 版权信息 |
WP_Image_Editor layer using the image library available on the server, normally GD or Imagick. New uploads can be optimized automatically, while existing media can be processed through a persistent background queue or WP-CLI.
The plugin is designed for WordPress sites and WooCommerce stores that want image compression, size reduction and modern-format delivery without per-image credits or an external image-processing account.
Learn more about Kitgenix at Kitgenix.
WordPress Image Optimization Features
big_image_size_threshold behaviour.<picture> delivery when corresponding sidecars exist.loading attribute management for frontend images..webp and .avif sidecars can be generated alongside the original file. The original source remains the fallback.
When sidecar delivery is enabled and the corresponding sidecar files exist, frontend image markup can be wrapped in a <picture> element containing AVIF and/or WebP <source> elements. AVIF is placed before WebP where both are available so a capable browser can choose the first supported modern format.
The delivery logic only rewrites images that resolve within the site's WordPress uploads directory. Remote images are not rewritten as if local sidecar files existed.
Resizing Oversized Images
Configured maximum dimensions integrate with WordPress's big-image threshold so the site does not unnecessarily perform one resize in WordPress core and a second independent resize in the plugin.
The optimizer preserves aspect ratio and relies on the active WordPress image editor for the actual image operation.
Metadata Stripping
Optional metadata stripping can remove image metadata during processing where supported by the active editor. This can reduce file size and may remove embedded EXIF/GPS information from images that are rewritten.
Because metadata requirements differ between sites, administrators should keep this disabled if they need embedded camera/copyright/location metadata to remain in optimized derivatives.
Backups and Restore
If Backup Originals is enabled before optimization, the plugin can retain an original backup file. A per-image restore action and WP-CLI restore command can put that backup back in place.
Restoring a master image regenerates WordPress attachment metadata and sub-sizes so the database dimensions and generated files stay aligned with the restored source.
Backup deletion on uninstall is separately configurable. Media Library originals are never treated as disposable plugin settings data.
Bulk Optimization Queue
Large libraries are handled through persisted queue state rather than one giant admin request. The queue can be started in normal bulk mode or re-optimization mode, paused, resumed, stopped and asked to retry failed items. Because it acts on every image in the library, the bulk queue is available to administrators only (manage_options); users who can upload files can still optimize or restore their own images individually.
A scheduled background runner continues processing queue batches after the administrator leaves the page. The admin interface can poll queue status and display processed/failed counts without requiring one PHP request to remain open for the entire library.
Exclusion Rules
The code includes exclusions for:
loading attributes to <img> elements that do not already declare one. The first image is left eager to avoid automatically delaying the likely Largest Contentful Paint candidate, while later images can receive loading="lazy".
The lazy-loading processor skips admin and other unsuitable contexts and does not overwrite an existing loading attribute.
Media Library and Attachment Tools
The Media Library receives optimization status/savings information and per-image controls. An attachment panel provides additional context for a selected image, and administrators can trigger single-image optimization or restore where permitted.
Side-by-Side Compression Preview
The "Compare Compression" button lives in the "Image Optimizer" box on an image's full Attachment Details edit page (post.php?post=<id>&action=edit) - not in the quick preview that opens when you click a thumbnail in the Media Library's grid view. To reach it: in the Media Library, switch to List view and click the file's name (or "Edit"), or from the grid view's quick preview click "Edit more details"/"Edit Image" first. Either route lands you on the same edit page, with the Image Optimizer box and its Compare Compression button in the sidebar.
Open it to see the current file next to a preview at each compression level: Conservative, Balanced, Aggressive and Maximum. Each preview shows the resulting file size and saving. You can zoom to 100% with both images scrolling together to check fine detail. When you're happy, optimize the image with the level you chose. This applies to that image only and does not change your global setting. Previews are encoded exactly as the real optimization would be, and nothing is changed until you commit. Temporary preview files are deleted automatically after an hour.
AJAX actions require both the plugin-level media capability and permission to edit the individual attachment.
Diagnostics and Site Health
Diagnostics report GD/Imagick availability and versions, preferred WordPress image editor, PHP memory information and encode/decode support for relevant formats. Site Health exposes the same capability picture and can warn when a feature such as WebP/AVIF conversion is enabled but the server cannot perform that conversion.
Optimization failure counts and queue status are also available for troubleshooting.
REST API
The plugin registers authenticated/read-only diagnostic routes under:
kitgenix-image-optimizer/v1
Routes provide status and capability information. They are intended for administration/diagnostics rather than remote image upload or third-party compression.
WP-CLI
The command base is:
wp kitgenix-optimizer
The code includes commands for server/queue status, optimizing all eligible images or a single attachment, forced re-optimization, statistics, backup restore and queue actions (start, pause, resume, stop, retry, status).
Privacy and Storage
Images are processed locally. Plugin settings, queue state, statistics, logs and per-image optimization metadata are stored in WordPress. Optional backup and sidecar files are stored in the site's uploads area.
The shared Kitgenix admin Hub can request public plugin-directory data from WordPress.org, and the admin stylesheet imports disclosed Google Fonts. Neither service receives image files for optimization.
Typical Uses
No. Processing is local through WordPress WP_Image_Editor. See External Services for non-image admin requests.
Yes. The queue supports optimization, re-optimization, pause/resume, and failed-item retry. Restore is available when Backup Originals was enabled before optimization.
It's not on the quick preview that opens when you click a thumbnail in the Media Library's grid view - that view has no room for it. Switch the Media Library to List view and click the file's name (or "Edit"), or click "Edit more details" from the grid view's quick preview, to open the full Attachment Details edit page. The "Image Optimizer" box in its sidebar has the "Compare Compression" button.
.webp/.avif sidecars and -kitgenix-original backup file, for the main file and every registered size. Previously these were never cleaned up, so disk usage from optimised sites grew without bound as media was deleted. Editing an image with WordPress's built-in editor (crop, rotate or scale) now also removes sidecars/backups left over from sub-sizes the edit replaced, and regenerates sidecars for the edited result when "Auto-Optimize on Upload" is enabled.wp kitgenix-optimizer clean-orphans WP-CLI command, to find and remove .webp/.avif sidecars and -kitgenix-original backups left behind by attachments deleted before this release, or by files removed outside WordPress's own deletion flow.post_thumbnail_html were wrapped in a <picture> element twice – once by the wp_get_attachment_image filter that wp_get_attachment_image() already applies internally, and a second time by this plugin's own post_thumbnail_html hook on top of that already-wrapped markup, producing invalid nested <picture><picture>...</picture></picture> output. The redundant post_thumbnail_html hook has been removed; featured images continue to get modern-format sources through the existing wp_get_attachment_image filter.<img> tag a theme, block or page builder had already placed inside its own <picture> element was wrapped a second time when it appeared in post content, for the same reason. Content image wrapping now skips any <img> that already sits inside an existing <picture>...</picture> block.manage_options capability. Previously any user who could upload files, including Authors, could start a site-wide bulk re-optimisation that recompressed other users' media./kitgenix-image-optimizer/v1/capabilities REST endpoint, which reports the server's exact GD and ImageMagick versions, is now restricted to administrators.Requires PHP: 8.2).Optimizer::prepare_editor() so previews and real optimisation always use the same pipeline. Added Optimizer::with_compression_level() to run an optimisation with a one-off preset. The single-image optimise AJAX action now accepts an optional compression_level.wp_nonce_field() output is already escaped by WordPress core, so this is a no-op code-quality fix.kitgenix_image_optimizer_preview_compression AJAX action and kitgenix_image_optimizer_cleanup_previews cron hook..pot translation template for 2.2.0.CHANGELOG.md.CHANGELOG.md file.