=== Reinvent Media Cleanup ===
Contributors: reinventwp
Tags: media cleaner, unused images, clean media library, delete unused media, optimize
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.4
Version: 1.0.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Find and safely delete unused images and media files. Works with Elementor, Divi, ACF, WooCommerce and every page builder, for free.

== Description ==

Media Cleanup finds the images and files your site no longer uses and removes them safely, so your backups get smaller and your uploads folder stays tidy.

**It reads your whole site, not just your posts.** Page builders (Elementor, Divi, Beaver Builder, Bricks, Oxygen, Breakdance, WPBakery, Avada…), custom fields (ACF, Meta Box, JetEngine), WooCommerce galleries and categories, sliders, theme settings, widgets, menus, theme files and the CSS that builders generate. No extra add-on per plugin and nothing behind a paywall.

**Nothing is deleted behind your back.** Files go to a private trash first. Restore anything in one click.

**The safety net.** If a visitor, Google or an old newsletter asks for a file you trashed, Media Cleanup notices and puts it back automatically, then keeps it out of future results.

= Why it's different =

* **Every builder supported, free.** Instead of a parser per plugin, Media Cleanup reads post content, all post meta, options, term and user meta, comments, other plugins' database tables, theme files and generated CSS as plain text. If an image is referenced anywhere, it's kept.
* **Honest results.** Each file is marked **Safe to remove** or **Check first**, with the reason in plain words: "Uploaded to *About us* but that page doesn't show it anymore", "Uploaded in the last 14 days", "PDFs are often linked from emails". If part of your site couldn't be read, results are marked "Check first" instead of guessing.
* **Uploads folder scan, free.** Finds files that aren't in the Media Library, leftover WebP/AVIF copies of deleted images, and old thumbnail sizes nothing uses.
* **Safe by design.** Never runs your shortcodes or page builder code during a scan. Re-checks posts you edited after the scan before moving anything.
* **Fast on big sites.** The scan runs in small steps that fit your server's time limit, resumes after a timeout, and keeps going in the background if you close the page.
* **Simple or Advanced.** Simple mode is one button and a list to review. Advanced mode adds the full scan report, every option, scheduled scans and an error log.
* **Search your settings in plain words.** Type "skip a folder" or "restore a deleted image" and jump straight to the right setting.
* **Media Library "Usage" column.** See where each image is used, from the last scan.
* **WP-CLI included.** `wp media-cleanup scan`, `list`, `trash --all-safe`, `restore`, `empty-trash`, `usage`.

= Free features =

* Media Library scan with confidence levels and reasons
* Uploads folder scan (orphan files, leftover WebP/AVIF/@2x copies, old thumbnail sizes)
* Missing-file detection (library entries whose file is gone)
* Private trash with previews, restore and permanent delete
* Safety net with automatic restore and a server self-test
* Optional automatic trash emptying after N days without visitor requests
* Daily or weekly scheduled scans
* Keep list (hide files you want to keep)
* Scan report: what was read, plugins and tables found, anything skipped
* Settings backup and restore
* WP-CLI commands

= Tip =

Like any cleanup tool, keep a recent backup before deleting files permanently.

== External services ==

This plugin works on your server. Your images and files are never uploaded anywhere. The plugin connects to one external service, operated by us:

**Reinvent WP Services** (services.reinventwp.com), used for four things:

1. Settings search. It finds the right setting when you describe what you want in your own words. When you type in the settings search box on the plugin's admin page, it sends the text you typed, the plugin name and the plugin version. Nothing is sent until you type a search.
2. Error reports. They help us fix bugs. They are sent only after you click "I Agree" on the privacy notice in the plugin's admin page. When the admin page hits an error, it sends the error message, the admin page URL (which includes your site address), your browser's user agent and the plugin version. Before you agree, errors are only saved in the plugin's own error log on your site.
3. The list of Reinvent WP apps on the **Reinvent WP → Dashboard** page. When an administrator opens that page, your site downloads the current list at most once a day and keeps a copy. Nothing about your site or you is sent.
4. The assistant (the **Describe a problem with your site** field) on the **Reinvent WP → Dashboard** page and on this plugin's page. When you send a question, it is sent with any screenshots or text files you attach to it (of a file, only its newest part, with emails, IP addresses, passwords and keys hidden by your browser first), the last few messages of the conversation and the list of Reinvent WP plugins on your site (whether each is active, inactive or not installed, and its version), so the answer can point to the right plugin and setting. Nothing is stored; the conversation stays in your browser tab. If you send feedback from the assistant's form, your email, site address and message go to the Reinvent WP team, like the feedback form.

Reinvent WP Services: [Terms of use](https://reinventwp.com/terms-and-conditions), [Privacy policy](https://reinventwp.com/privacy).

== Source Code ==

The source code is on https://github.com/reinventwp/reinventwp-apps.

== Installation ==

1. Install the plugin from **Plugins → Add New** (search for "Reinvent Media Cleanup"), or upload the zip.
2. Activate it. You land on **Media → Cleanup**.
3. Click **Scan my site**, then review the results.

== Frequently Asked Questions ==

= Will it delete images my page builder uses? =

Media Cleanup reads page builder data directly (for example Elementor's `_elementor_data`, Divi shortcodes, Beaver Builder settings), plus custom fields, plugin tables and generated CSS. If a file is referenced anywhere in that data, it's kept. Anything uncertain is marked "Check first".

= What happens when I move a file to the trash? =

The file and all its resized copies move to a private folder in `wp-content` that visitors can't open. The Media Library entry is hidden but kept. Restore puts everything back exactly where it was.

= What is the safety net? =

When someone requests a trashed file's URL, the request reaches WordPress because the file is missing. Media Cleanup recognizes the path, records the request and (by default) restores the file immediately. Use **Test now** on the Home screen to check your server supports it.

= Does it work on large sites? =

Yes. The scan works in small steps that fit your server's time limit and saves its progress after each one. Close the page and it continues in the background with WP-Cron, or run `wp media-cleanup scan` over SSH.

= Does it support multisite? =

Each site is scanned on its own from its own Media → Cleanup screen.

= What does "Check first" mean? =

The file looks unused, but there's a reason to look before removing it: it's still attached to a page, it was uploaded recently, it isn't an image (PDFs are often linked from emails), or part of your site couldn't be read.

= Is anything sent to your servers? =

Only what you type into the settings search, and error reports from the admin page. See External Services above.

== Screenshots ==

1. Home: how much you can free up, and what to review first.
2. Review: every file with the reason it was flagged.
3. Trash: restore or delete for good, with visitor requests highlighted.
4. Settings search: describe what you want in your own words.

== Changelog ==

= 1.0.4 =
* New: describe a problem with your site on the Reinvent WP → Dashboard page, and the assistant suggests the Reinvent WP app that fixes it.
* New: the Reinvent WP → Dashboard page shows your Reinvent WP apps first, then the others you can install, from an up-to-date list (read once a day, with a built-in list as fallback). Each app links to its own page.

= 1.0.3 =
* New: missing files that a post still uses are now reported in a "Broken on site" group, listed first with links to the posts that show a broken image. They are never moved to the trash.
* Fixed: the "Move all to trash" confirmation now shows the total size of every matching file, not only the files on the current page.

= 1.0.2 =
* Fixed: after moving files to the trash in bulk, the dialog title no longer reads "Move 0 files to the trash?"; it shows that the move finished.
* Fixed: Tools > Site Health now shows the new uploads folder size right after files move to the trash, are restored or are deleted, instead of the old cached size.

= 1.0.1 =
* Fixed: checkboxes in the Review and Trash lists now respond to a click anywhere on the box, not only on one corner.

= 1.0.0 =
* First release.
