HXMC — Smart Media Cleaner
HXMC keeps your media library tidy with three focused tools — and an honest scope for each.
1. Usage scan (read-only) Detects references to each image in featured images, post content (all intermediate sizes covered), custom fields, and widgets/options. Images with no detected reference are flagged as “No reference found” — deliberately not “unused”, because the scanner cannot see theme/CSS hardcoded URLs, serialized page-builder data, or external sites. This version never deletes anything. The list is there to inform your own decision.
2. Safe rename for non-ASCII filenames Japanese (or any non-ASCII) filenames cause percent-encoded URL mess and occasional server-side trouble. HXMC renames the original file and every intermediate size on disk, rewrites URLs in post content and custom fields, and registers a 302 fallback redirect for the old URL — so nothing breaks even where a reference could not be rewritten. Redirects fire only on 404, costing nothing on normal requests. GUIDs are left untouched, per WordPress convention.
3. WebP conversion with built-in compression
Generates .webp twins for the original and all sizes using GD or Imagick — entirely on your server, no external API. Compression is simply the WebP quality setting (default 82): one knob, not two features. Originals are kept on disk as insurance, references are rewritten to .webp, and old URLs get the same 302 fallback. Already-WebP files, SVGs, and animated GIFs are honestly refused rather than silently mangled.
For the ~2% of browsers without WebP support, HXMC writes Accept-header fallback rules to uploads/.htaccess (Apache/LiteSpeed): requests for .webp from non-supporting browsers are transparently served the kept original, with Vary: Accept so caches stay correct. On Nginx, where plugins cannot write server config, the admin page shows an equivalent copy-paste snippet instead.
4. In-place compression (overwrite mode) Re-encodes JPEG (quality knob, shared with WebP — one quality concept) and losslessly recompresses PNG, overwriting the same filename so URLs never change and no database rewrite is needed. Files are overwritten only when the result is smaller; otherwise the original bytes are kept. This is lossy for JPEG and irreversible — the confirm dialog says so plainly, and no backups are made (doubling disk usage would contradict the point of a cleanup plugin). JPEG metadata (EXIF) is stripped as part of the diet when Imagick is available.
5. Media replace (same filename, fresh cache)
Upload a new file over an existing attachment: the filename — and therefore every URL — stays identical, thumbnails are regenerated (old size files are cleaned up, stale size references in content are healed), and references get a ?v={timestamp} cache-busting parameter so browsers and CDNs fetch the new bytes immediately. WebP twins and compression state are reset, with content references rewritten back and 302 entries covering stragglers. Same MIME type only — keeping a .jpg name on PNG bytes would be a lie.
Design principles (HX Series)
* Admin-only. Zero JavaScript, zero markup, zero cookies added to your visitors’ pages. The only front-end footprint is a 404-time redirect lookup.
* No external services. Image processing is local GD/Imagick.
* 302 only — never 301 — so redirects are never cached into permanence.
* Fires hxmc_after_rename and hxmc_after_convert actions for integration (e.g. HXMD — Markdown Log Manager).
