=== Unused Media Review ===
Contributors: quintaphon
Donate link: https://buymeacoffee.com/quintaphon
Tags: unused media, media cleanup, media library, delete unused images, storage
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.2
Stable tag: 2.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Find the media nothing on your site uses, review it with thumbnails, and remove what you pick into an archive you can restore.

== Description ==

Over the years a Media Library fills up with images from deleted posts, replaced logos, test uploads and files nobody remembers. They take space on the server and in every backup.

Unused Media Review finds them, shows them to you, and lets you decide.

* **A thorough scan.** A media item counts as used when it is linked or inserted in a post, page or product, set as a featured image, part of a gallery or a WooCommerce product gallery, stored in a custom field (ACF and page builders included), used as a category image or user picture, set as site icon, logo, header or in a widget, or named in your theme files.
* **Review with thumbnails.** Every unused item is shown with its thumbnail, file name, type, size, upload date and the post it was attached to. Filter by images, video, audio and documents, and search by name.
* **Keep what you want.** Mark items as kept and later scans leave them out.
* **Remove into an archive.** Removed items leave the Media Library, but their files and database rows are saved in an archive. One click on Restore brings them back with the same ID, title, alt text and captions.
* **Checked again before removal.** Just before an item is removed, posts changed since the scan and the site settings are read again. An item that is used by then is left alone.
* **Delete for good only on purpose.** Permanent deletion needs DELETE typed in the dialog.
* **Works on large sites.** The scan runs in short steps, so it never hits a PHP time limit, and a progress bar shows where it is.

= Built to be careful =

* Recent uploads (the last 7 days) are skipped by default, since they may belong to a post still being written.
* Posts in the trash, drafts and scheduled posts count as using their media.
* You can also count media attached to a post as used, even when the post does not show it.

The plugin adds a screen under Media > Unused Media for administrators. It adds nothing to the front end of your site, sends no data anywhere and loads no external files.

Plugin site: [quintaphon.com/wordpress/unused-media-review](https://quintaphon.com/wordpress/unused-media-review/)

== Installation ==

1. Upload the plugin in Plugins > Add New Plugin > Upload Plugin, or install it from the plugin directory.
2. Activate it.
3. Open Media > Unused Media and click Review, then Scan for unused media.

Take a backup of your database and the uploads folder before removing media from a live site, as you would before any bulk change.

== Frequently Asked Questions ==

= Is a scan safe to run on a live site? =

Yes. A scan only reads. It changes no file and no database entry, apart from saving its own results.

= How do I undo a removal? =

Open Media > Unused Media > Archive and click Restore next to the removal. The items come back to the Media Library with their files, and with the same ID when it is still free.

= Can a scan miss a use? =

A plugin or theme can store media in a way no scan can know about, for example an ID computed in code. That is why removals go to an archive first. Browse your site for a few days after a removal, then delete the archive.

= Why is an image I never use not listed? =

Something points to it: a link, its file name, or its ID in a custom field or setting. Images added in the last 7 days and kept images are left out too.

= Where are the archives, and what happens to them when I delete the plugin? =

In `wp-content/uploads/unused-media-review-backup/`. They stay when you delete the plugin, because they hold your files. Delete them under Archive first, or remove the folder yourself.

= Does it work with images on a CDN or offloaded to cloud storage? =

The scan works on the Media Library and your site's data. Removing an item moves the files that are in your uploads folder; copies on remote storage are handled by your offload plugin, if it reacts to deleted media.

== Screenshots ==

1. Overview: media items, unused items waiting for review, kept items and the archive.
2. Scan with its options and the result.
3. Review grid: unused media with thumbnails, filters and selection.
4. Removing to the archive, with a fresh check of every item.
5. Archive with Restore and Delete.

== Changelog ==

= 2.0.0 =
* Rebuilt for every site: a full scan of posts, custom fields, term and user data, settings, widgets and theme files replaces the fixed list of items.
* New screen under Media > Unused Media with Overview, Review, Kept and Archive.
* Review grid with thumbnails, type filters, search, paging and select all.
* Keep items so later scans leave them out.
* Removed items go to an archive with their files and database rows; Restore brings them back with the same ID.
* Every item is checked again just before it is removed.
* Deleting for good needs DELETE typed in the dialog.

= 1.0.2 =
* Faster check of the listed items.

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 2.0.0 =
Works on any site now: scan, review, keep, and remove into an archive you can restore.
