WordPress plugin
A plugin that rewrites every image URL WordPress renders — post content, featured images, srcset — to route through Image Optimizer, without touching theme templates. This page documents the planned design; it is not implemented yet.
Why hooks instead of HTML rewriting
Existing plugins in this space (e.g. Statically) rewrite output HTML with a regex over the full page buffer — it works, but it is fragile against markup it did not anticipate, and it has to reverse-engineer which strings are asset URLs. WordPress already exposes the points where it builds an image URL, so the plan is to hook those directly instead of parsing HTML after the fact:
wp_get_attachment_image_src— rewrites the URL returned for a specific attachment size.wp_calculate_image_srcset— rewrites every entry in a generatedsrcset, so responsive images stay correct.
Mapping WordPress sizes to API parameters
For a requested attachment size, the plugin resolves the pixel width WordPress already computed and maps it straight onto our real query parameters:
https://image-optimizer-two.vercel.app/img/example.com/wp-content/uploads/2026/01/photo.jpg?w=<width>&f=auto&q=<default_quality>No custom transformation-flag syntax to design — w, h, q, and f are the same parameters documented in Parameters.
Planned settings screen
- API base URL and API key.
- Default output format and quality.
- Domain/path exclusions (e.g. skip images already on a CDN).
Open questions
- Whether to also rewrite block-editor inline styles that reference background images (Statically handles this via output buffering; worth deciding if it is in scope for v1).
- Bulk cache-warming for existing media libraries on activation.