=== Image Cleaner DL ===
Contributors: devlemon
Tags: media, images, cleanup, storage, media library
Requires at least: 6.5
Tested up to: 7.0
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 potentially unused WordPress images, review references, and safely remove unwanted media to reclaim storage space.

== Description ==

**Image Cleaner DL** helps you identify media files in your WordPress library that may no longer be in use, understand how much storage they occupy, and remove them safely — one at a time or in bulk.

**How it works**

Every image is scanned against known WordPress reference sources before being flagged. The plugin never assumes an image is unused without checking.

**Reference checks performed:**
- Post parent relationship
- Featured images (`_thumbnail_id` in all post types)
- Site icon
- Custom logo (theme mod)
- Image URLs and block editor IDs in post content
- WooCommerce product gallery images (when WooCommerce is active)

**Conservative design**

Images are never deleted automatically. The workflow is always: Scan → Review → Protect or Delete. Each deletion requires an explicit confirmation.

**Confidence levels**
- **Potentially Unused** — no known references found
- **Needs Review** — attached to a trashed or deleted post; manual verification recommended
- **Protected** — one or more known references found

**Keep protection**

Mark any image as Keep to exclude it from future scan results. Remove the protection at any time from the Protected tab.

**Batch scanning**

Large libraries are processed in configurable batches to avoid PHP timeouts. A progress bar shows real-time scan status.

**File size analysis**

Disk usage is calculated per image including the original file and all generated thumbnail sizes, so you know exactly how much space you stand to recover.

**Privacy**
No data is sent to external servers. All analysis happens within your WordPress installation.

**Limitation**
Some themes and plugins store media references outside standard WordPress fields. Image Cleaner DL cannot detect those custom references. Always review files before deleting them.

== Installation ==

1. Upload the `image-cleaner-dl` folder to `/wp-content/plugins/`.
2. Activate the plugin through the Plugins menu.
3. Go to **Media → Image Cleaner DL**.
4. Click **Scan Media Library** and wait for the scan to complete.
5. Review results, mark files to keep, and delete with confirmation.

== Frequently Asked Questions ==

= Is it safe to delete images identified as "Potentially Unused"? =
The plugin checks known WordPress reference types, but themes and custom plugins may store image references in non-standard ways. Always review each file before deleting it, and consider making a backup first.

= Will the plugin delete images automatically? =
No. Version 1.0.0 does not include any automatic deletion. All deletions require explicit selection and confirmation by an administrator.

= What does "Needs Review" mean? =
The image was previously attached to a post (post_parent was set), but that post has been deleted or moved to the trash. It may or may not be needed.

= What happens to generated thumbnail sizes when I delete an image? =
WordPress's `wp_delete_attachment()` API is used, which removes the original file and all registered thumbnail sizes associated with the attachment.

= Can I protect an image from appearing in future scans? =
Yes. Click **Keep** on any image in the scan results. Protected images appear in the Protected tab and are excluded from future Potentially Unused lists.

= Does it work with WooCommerce? =
Yes. When WooCommerce is active, product gallery images are identified as protected so they are not flagged as unused.

= Does it work with large media libraries? =
Yes. The scanner processes images in configurable batches (default: 50 per batch) to avoid server timeouts.

== Screenshots ==

1. Image Cleaner DL overview and media library statistics.
2. Media scan results with reference and storage information.
3. Safe confirmation before deleting selected media.
4. Protected media list managed manually with Keep.
5. Image Cleaner DL settings.

== Changelog ==

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
