=== Bright Addons Media Cleanup ===
Contributors: nayem07
Tags: media cleaner, unused images, delete unused media, clean up, disk space
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Find unused images and files in your Media Library and remove them safely. Elementor, ACF and WooCommerce aware, with a quarantine you can restore.

== Description ==

**Is your hosting running out of space?** Most WordPress sites carry gigabytes of images nobody uses any more: old banners, test uploads, replaced product photos, every thumbnail size of each one.

**Bright Addons Media Cleanup** scans your whole site, shows you exactly which media files are not used anywhere, and lets you remove them **safely**. Nothing is deleted straight away. Files first go to a **quarantine**, so you can check your site and restore anything with one click.

= Why it is safe =

A file is only listed as unused when it is found **nowhere**. The scan checks:

* **Post and page content**: image classes, links, galleries and shortcodes (WPBakery and similar), plus Gutenberg block attributes
* **Elementor**: every widget, section background, page settings and Site Kit settings. This also covers Elementor addon packs such as [Bright Addons for Elementor](https://wordpress.org/plugins/bright-addons-for-elementor/)
* **ACF (Advanced Custom Fields)**: image, file and gallery fields, including repeaters, flexible content, ACF blocks, term and user fields and options pages
* **WooCommerce**: product images, product galleries, variation images, category thumbnails, downloadable files and the placeholder image
* **Featured images**, widgets, menus, Customizer, site logo and site icon, Yoast and Rank Math social images
* **Your theme files**: hardcoded image paths and IDs in the active theme, the parent theme and must-use plugins
* **A full database sweep**: every text column of every table, to catch other page builders, sliders, form plugins and custom tables
* **Every size and format**: resized thumbnails, `-scaled` originals, edited images and WebP/AVIF copies all count as one image
* **Shared files**: when translation plugins (WPML, Polylang) share one file between media items, both are kept if either is used

Before each file is moved, the plugin checks again that it has not become a featured image, gallery image, logo or icon since the scan.

= Features =

* Scan in small background steps with a **live progress bar and percentage**. It never times out, even on very large libraries, and you can resume a stopped scan.
* **Unused media** list with thumbnail, size, date and total recoverable space
* **Used media** list that shows where each file is used, with links to edit the page
* **Keep**: protect any file from cleanup for good
* **Quarantine**: unused files are moved to a protected folder and hidden from the Media Library, with nothing deleted
* **Restore** with one click, back to exactly the same place
* **Delete permanently** from quarantine when you are sure, which frees the disk space
* Filter by type (images, videos, audio, documents) and search by file name
* Warning when content changed after the last scan
* Skip list for tables that list every file (image optimizers, security plugins, logs)
* Uninstalling puts every quarantined file back automatically

= Media Cleanup Pro =

[Media Cleanup Pro](https://brightaddons.com/media-cleanup/) adds:

* **One click for everything**: "Quarantine ALL" and "Empty quarantine" for thousands of files at once
* **Orphan files**: finds files in your uploads folders that are not in the Media Library and not used anywhere (leftover thumbnails, FTP uploads, failed imports)
* **Disk usage report**: see which folders fill your hosting space (backups, caches, logs, plugin data)
* **Scheduled scans** (daily or weekly) with an email report
* **CSV export**
* **WP-CLI** commands for very large sites
* Priority email support

= More free plugins from Bright Addons =

* **[Bright Addons for Elementor](https://wordpress.org/plugins/bright-addons-for-elementor/)**: 53 free Elementor widgets, including Nav Menu with mega menus, Form Builder and a Header & Footer Builder. Each widget loads its code only on pages where it is used.
* **[Bright Addons Blocks Library](https://wordpress.org/plugins/bright-addons-blocks-library/)**: 54 ready-made blocks for the WordPress block editor, with entrance animations, a header and footer builder, mega menus and multilingual support.

== Installation ==

1. Go to **Plugins > Add New**, search for "Bright Addons Media Cleanup" and click **Install**, then **Activate**.
2. Open **Media > Media Cleanup**.
3. **Make a full backup of your site** (files and database).
4. Click **Start scan** and wait for 100%.
5. Review the **Unused media** tab. Click **Keep** on anything you want to protect.
6. Select items and click **Quarantine selected**. Tick the box in the table header to select the whole page.
7. Check your site. If everything looks right, go to **Quarantine** and delete permanently to free the space. If something is missing, click **Restore**.

== Frequently Asked Questions ==

= Will it delete images that my site uses? =

It is built to prevent exactly that. A file is only listed when it is not found in content, Elementor, ACF, WooCommerce, theme settings, theme files or any database table. Even then, files go to quarantine first and can be restored with one click. Always keep a backup before any cleanup.

= Does scanning change anything? =

No. Scanning only reads your site. Nothing is moved or deleted until you click a cleanup button.

= Does quarantine free disk space? =

Not yet. Quarantine moves files to `wp-content/uploads/bamc-quarantine/` on the same disk. The space is freed when you delete them permanently from the Quarantine tab.

= Almost everything shows as "used". Why? =

Some plugins (image optimizers, security scanners, logs) keep a table that lists every file. Check **Top reference sources** on the Scan tab. If one table references almost everything, add it to the skip list on the same tab and scan again.

= My site is very large. Will the scan time out? =

No. The scan runs in short steps of a few seconds each and keeps going until it finishes. If you close the tab, open the page again and click **Resume scan**.

= What happens if I uninstall the plugin? =

Every quarantined file is restored to the Media Library first. Then the plugin removes its own tables and settings.

= Does it support multisite? =

Yes. Each site in the network is scanned on its own, from that site's dashboard.

= Is my data sent anywhere? =

No media data leaves your site. See the "Privacy" section below about the optional usage-data opt-in.

== Privacy ==

This plugin uses the [Freemius](https://freemius.com) SDK to handle the optional opt-in for usage data and update notices. Nothing is sent unless you choose to opt in. If you opt in, basic site and plugin information (such as WordPress, PHP and plugin versions, site URL and admin email) is sent to Freemius. See the [Freemius Privacy Policy](https://freemius.com/privacy/) and [Terms of Service](https://freemius.com/terms/).

The media scan itself runs only on your server. No file names, images or content are sent to any external service.

== Screenshots ==

1. Unused media: files not used anywhere, with size and total space you can recover.
2. Used media: shows exactly where each file is used (Elementor, ACF, WooCommerce, content and more).
3. Scan with live progress and the top reference sources.
4. Quarantine: restore with one click, or delete permanently to free disk space.
5. Pro: disk usage report and orphan files.

== Changelog ==

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.0.0 =
First release.
