=== EvoMedia - Link-Safe Media Replace & Convert ===
Contributors: gfxproductions
Tags: replace image, media library, webp, convert images, serialized data
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Swap the file behind any attachment — same format or JPEG to WebP — and every reference in your posts, meta and page builders is rewritten for you.

== Description ==

WordPress will not let you change the file behind an existing attachment. You delete, re-upload, then hunt down thirty broken images by hand.

EvoMedia replaces the file in place, keeps the attachment ID, and **rewrites every reference to it across your whole database** — post content, postmeta, and the serialized structures page builders and custom fields store their data in.

That last part is the whole point. An image URL is not only in your post content. It is buried inside Elementor's JSON, inside ACF fields, inside WooCommerce gallery meta — all of it serialized, where a naive search-and-replace corrupts the data and takes the page down with it. EvoMedia unserializes, replaces, and re-serializes each value, so the byte lengths stay correct and nothing breaks.

The same engine then lets it do something no image optimizer does: **convert a JPEG to WebP and keep the attachment**, renaming `photo.jpg` to `photo.webp` and repointing every reference at the new file. Other plugins keep the original and add a parallel file served through an `.htaccess` rule, a `<picture>` tag or a CDN. EvoMedia changes the actual file on your disk. There is no rewriting layer at page-render time — nothing to break when you switch hosts, and nothing to un-install later.

Everything runs on your own server, through Imagick or GD. No account, no API key, no credits, no monthly quota, no upload limit. Your images are never sent anywhere.

= What it does =

* **Replace media, safely** — upload a new file over an existing attachment. Keep the current file name and the URL never changes; or adopt the uploaded file's name; or change format entirely. Every reference across posts and postmeta is rewritten, serialized data included. Optionally back up the current file first, edit the title, set the date.
* **Convert to WebP, AVIF or JPEG** — whichever your server can encode, automatically on upload or in bulk across your existing library, with progress feedback. The System Info page shows exactly which formats your image driver supports.
* **Backup and restore** — the original is archived before every conversion, and can be restored or deleted per image or in bulk.
* **Compression quality** — one slider, from 10 to 100. A master switch turns the engine off without deactivating the plugin.
* **Control Center** — your whole library on one screen: sort, search, preview, download, see each file's format, size and backup state.
* **System Info** — a one-click report of what your server can actually do, and of every other plugin EvoMedia has to coexist with.

= Why the serialization matters =

Try this with any other tool: put an image in an Elementor section, then rename the file. Elementor stores its layout as a serialized PHP array inside postmeta, and every string in it is prefixed with its own byte length. Change `photo.jpg` to `photo.webp` with a plain SQL replace and the recorded length no longer matches the string. PHP refuses to unserialize it. The section disappears.

EvoMedia walks the structure, replaces the value, and lets PHP recompute the lengths. This is why it can offer replace, format conversion and (in the Pro add-on) renaming at all — and it is the part that took the longest to get right.

= Built to coexist =

Media plugins break each other. EvoMedia is written to notice what else is installed:

* **WPML and Polylang** — translated attachments share one file. EvoMedia keeps every language sibling in sync and collapses duplicates in its own tables.
* **Page builders** — Elementor and friends store their data as slashed JSON inside postmeta. EvoMedia writes exact bytes rather than letting WordPress re-escape them.
* **Cloud offload** — if WP Offload Media, Cloudinary, Media Cloud, WP-Stateless or S3 Uploads is active, EvoMedia refuses to touch the files rather than corrupt your remote bucket, and tells you why.

= Requirements =

PHP 8.1 or later, and either Imagick (recommended) or GD. Which output formats you can use depends on your host's image driver — WebP and AVIF are common, JPEG XL is rare; the System Info page tells you exactly what your server can do.

= EvoMedia Pro =

A separate, commercial plugin — [EvoMedia Pro](https://store.gfxproductions.com) — is available from the author's own site. It is a different plugin, downloaded from there and installed alongside this one. It adds bulk renaming from the Media Library, a cleanup tool for WordPress's oversized `-scaled` originals, and a backups manager.

**None of that code is in this plugin.** This plugin is not a trial and has nothing locked, disabled or limited. There is no licence check, no upsell nag, no counter, no expiry, and no cap on how many images you may process. Everything it ships, it does.

== Installation ==

1. Upload the `evomedia` folder to `/wp-content/plugins/`, or install it through **Plugins → Add New**.
2. Activate it through the **Plugins** menu.
3. Go to **EvoMedia → Format Conversion** to choose your target format and quality.
4. Upload an image, or select existing ones and run a bulk conversion.

Visit **EvoMedia → System Info** first if you are unsure whether your server supports WebP.

== Frequently Asked Questions ==

= Will converting break the images already used in my posts? =

No. EvoMedia keeps the attachment and updates WordPress's own metadata, so everything that renders through WordPress keeps working. And if a replace changes the file's name or its format, every reference in posts and postmeta is rewritten to match — serialized data included.

= Will replacing an image change its URL? =

Only if you ask it to. Keep the current file name and the URL stays identical: nothing anywhere needs updating. Choose the uploaded file's name, or a different format, and EvoMedia rewrites every reference for you. Be aware that if other websites link straight to the old file, those links will break — that is unavoidable once the filename changes.

= Can I go back to the original file? =

Yes. Tick "Backup originals before converting" and the original is archived before each conversion. Restore it from the Backup Status column, per image or in bulk.

= Which output formats can I choose? =

Whichever your server's image driver can actually encode — commonly WebP, AVIF and JPEG, and JPEG XL on the rare host whose Imagick was built with it. Only formats your server can write are listed: nothing is shown that you cannot select and use immediately, and nothing your server supports is held back. The System Info page reports exactly what your image driver can do.

= Why does it convert the file instead of serving a WebP copy? =

Because a parallel copy has to be delivered by something: an `.htaccess` rule, a `<picture>` tag rewrite, or a CDN. That layer can fail silently, breaks when you move host, and leaves orphaned files behind if you ever remove it. EvoMedia converts the file itself and repoints every reference at it. What is on disk is what is served, by WordPress, with no help from anything.

= What happens to my images if I deactivate the plugin? =

Nothing. Converted files stay where they are and keep being served. EvoMedia does not proxy or rewrite anything at page-render time.

= I use WP Offload Media. Why are the Replace buttons missing? =

Because your files live in a remote bucket, and rewriting them locally would leave your site pointing at stale objects. EvoMedia detects the offload plugin and steps aside. If you know what you are doing, the `evomedia_allow_with_offload` filter overrides this.

= Are there any limits, caps or trials? =

None. No image quota, no counter, no expiry, no licence key, and no feature switched off waiting to be unlocked. Everything in this plugin works from the moment you activate it.

= Does it send my images anywhere? =

No. Conversion runs on your own server through Imagick or GD. The plugin makes no network requests of any kind.

== Screenshots ==

1. The Control Center: your whole library, with format, size, backup status and per-row actions.
2. Replace media: current file and new file side by side, before you commit.
3. Upload settings, reachable from the WordPress uploader without leaving the page.
4. System Info, with a one-click report to paste into a support ticket.

== Changelog ==

= 1.1.0 =
* First public release.
* Replace media: swap the file behind an existing attachment, keeping its ID and URL, with an optional backup of the current file, an editable title, and a date option.
* Control Center: sortable columns, search, per-format colour badges, and an image preview lightbox.
* Upload settings moved into a slide-out panel, reachable straight from the WordPress uploader.
* New System Info page, with a one-click report to paste into a support ticket.
* Compatibility: WPML and Polylang sibling sync; page-builder-safe metadata writes; cloud offload plugins detected, with media actions disabled rather than corrupting your bucket.
* Fixed: replacing an image larger than 2560px left the site's references pointing at WordPress's full-size original instead of the served file.
* Fixed: admin thumbnails kept showing the previous image after a replace, until a hard refresh.
* Fixed: two elements of the Replace dialog were displayed even when they should have been hidden.

== Upgrade Notice ==

= 1.1.0 =
First public release.
