This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Description

Did you ever scale or crop uploaded images in wordpress? Did you ever try various image generating plugins? Did you ever change or add various media image sizes? If yes, chances are that your content folder is full of unused and unreferenced images. These image leftovers will remain cluttering your content folder until the end of days.

Image Cleanup will index these (and many more) unreferenced images. Unreferenced images are not indexed in the wordpress database and also not used by posts, scripts or backup restore meta data. Please note that images which have valid database metadata but are not used in posts are not indexed at this time. This is beyond the scope of this plugin.

Image Cleanup will also find images without meta data and images with incorrect meta data.

  • Save space taken up by unreferenced/backup images!
  • Fix incorrect metadata (sizes)
  • Bulk repair/delete functionality
  • Pagination for extremely large result sets
  • Logs tabs easily visible for reviewing!
  • Detailed information in log tabs!
  • Full restore functionality!
  • Especially useful for developers!
  • Written as class to avoid any conflicts!
  • Highly configurable to avoid memory and/or timeouts on some setups

On my one month old website with 50 files (and 250 attachment size variants) this plugin found 95 unreferenced images which I could remove without any conflicts.

There has been a reported case where this plugin indexed and removed over 23.000 images on a website. See forum/review for details

Image Cleanup workflow details

  • Retrieves all attachment images from the database (including size variants);
  • Finds all images in the wp-content folder;
  • Subtracts the attachment (and size variants) from physical found images;

The above will result in an list of invalid images which are not referenced by the database

  • Posts will be searched for images and found images will be subtracted from the invalid files (if any);
  • Scripts in wp-content will be searched for images and they will be subtracted from the invalid files (if any);
  • Backup images (for restoring images after scale/crop) will be subtracted from the invalid images;
  • Found unreferenced files will be checked against the meta data to see if the database meta entry still exist;

This results in various image lists in which the images can be reviewed, repaired or removed.

After indexing

After indexing you are able to (temporary) move the images to a backup folder to check the site without the images in the wp-content folder. You could also check the logs in the ../wp-content/uploads/image-cleanup/ID/logs folder for full information about the index.

If any problems are found you can revert the move of images by restoring them to their original locations.

When no problems arrise after moving the images to another location it is possible to permanently remove the images.

Future planned additions

  • Index unused valid images
  • Index missing image sizes (and option to generate missing images)
  • Index missing images which are used in posts

Screenshots

  • Image Cleanup Index Images (screenshot-01.png)
  • Overview Admin Table (screenshot-02.png)
  • File Admin Table (screenshot-03.png)

Installation

  1. Upload Image Cleanup to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Go to the administration page: Tools > Image Cleanup
  4. Initiate index images
  5. Check log tabs for detailed information
  6. Choose to move files to temp location
  7. Restore or delete files from temp location
  8. Clutter free content folder! 😉
  9. After step 5. you can also repair/delete specific meta data (re-indexing required after changes)

FAQ

Installation Instructions
  1. Upload Image Cleanup to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Go to the administration page: Tools > Image Cleanup
  4. Initiate index images
  5. Check log tabs for detailed information
  6. Choose to move files to temp location
  7. Restore or delete files from temp location
  8. Clutter free content folder! 😉
  9. After step 5. you can also repair/delete specific meta data (re-indexing required after changes)
Will Image Cleanup delete, move or rename images?

When indexing the images Image Cleanup will not delete, move or rename any image.

Images will only be moved when you choose to. Only after the move of images an permanently delete option will be available.

Can I revert back to previous state?

Yes you can! Full restore functionality is present.

What if the index is not finishing?

It might take a while for the plugin to index all the files. Please give it enough time to run!

If the index is returning an error this will be clearly visible. An bold red text will appear with a link to the debug log. Please send me this and the other logs.

If your image base is huge (50.000 or more images) you might want to exclude some parts of the image paths and work your way from year to year.

For example: exclude all folders which have the text ‘/2010/’, ‘/2011/’ etc. Do not remove the ‘/’ slashes because without it will also remove filesnames containing ‘2010’. Scan only one year by excluding all the others.

Then, after the index is done and you removed the images you are able to index other years of the content folder.

Did you get any help?

Yes, I would like to say thank you to: Kelly Rosal and Tali Walt for letting me test and debug the plugin on their websites. Their websites were very though to run a full index through and because of that I had to optimize the plugin a lot!

Reviews

Mayo 28, 2019
Worked perfectly on an up-to-date WordPress installation. My site uses a plain old theme, not a page builder, and it does not have any fancy image related plugins (except this). Indexing, analyzing results, moving, testing, then deleting is a safe way to proceed: Once the files (suggested by the plugin and selected by the user) are “moved” to another folder, one has to verify the integrity of the site by actually browsing it. If everything seems fine, the files can be deleted immediately or at some later point in time. If something gets broken, some or all files can be moved back = full/partial undo. I love how this plugin puts the user in charge. I also appreciate that this thing detects/reports invalid metadata, too.
Disyembre 26, 2018
Wow. I’ve been piddling around with my site for months, and really there’s not a great deal to it, just 6 pages. But over those months, I’ve tried an inordinate number of layouts, templates (Elementor) and swapped in and out different images, etc. I threw this puppy in on a recommendation and found I had 1650+ unused images in the database. Are you NUTS? So I went in and deleted them all. I had to step through 16 pages of lists to delete them all (although each page has a select ALL button for each page), so the process took a few minutes. I still wasn’t convinced I could possibly have accumulated THAT many images, so to see if there was any difference in the size of my site, I exported the database using All In One Migration (another superb plugin), and LO AND BEHOLD, my database has shrunk from 6000+ files to 4000+ files! But, moreover, the database had shrunk from 378 MB to 275 MB. The difference in page loading? Not much that I could detect; however, migrating the database was another story: much faster. Recommend this plugin! Did a great job. Try it. You might find that your ‘innocuously’ small website that you’ve been fussing with over the months has got some serious backend baggage!
Read all 64 reviews

Contributors & Developers

“Image Cleanup” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Image Cleanup” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

1.9.2

  • Fixed error minimum version on PHP 7.0
  • Fixed Strict Standards warnings
  • Compatibility with 4.7
  • Fixed many notices of undefined variable
  • Validate and sanitize user data

1.9.1

  • Fixed error where meta data could not be removed, thanks Squill1959

1.9.0

  • WARNING: All current index information is removed for this upgrade!
  • Changed all file reads into memory efficient loads
  • Better memory management e.g. unsetting unused array vars
  • Saves category counts into variable for faster browsing
  • Skip image paths now also skip the attachment metadata with same paths
  • Fixed incorrect meta size after re-index when removing backup metadata
  • Improved and fixed some layout glitches
  • Improved retaining index position of moved files after re-index
  • Fixed some warnings when logs are read but not created
  • Added reset plugin option (devs only)

1.8.2

  • Fixed error on invalid metadata

1.8.1

  • Added check if meta image path was set

1.8

  • Fixed potential errors where getimagesize was not checked for results
  • Cleaned up parts of code
  • Fixed url of log files in general tab
  • Cleaned up wordpress ThickBox css

1.7.8

  • Added quickview of image by clicking on filename

1.7.7

  • Adjusted options save method
  • Added setting to choose how many posts should be processed each step

1.7.6

  • Fixed general actions not showing up
  • Fixed posts not being scanned
  • Broke up post scanning in multiple ajax calls

1.7.5

  • Fixed UTF8 basename bug (PHP bug)
  • Improved comparision functions

1.7.4

  • Added additional debug information
  • Fixed debug log link not working

1.7.3

  • Fixed error handling when image dimensions could not be read

1.7.2

  • Small bugfix which prevented ajax loops on some platforms

1.7.1

  • Small bugfix to check if meta size is available

1.7.0

  • Added upgrade code to avoid errors in older versions
  • Fixed a lot of warnings when E_NOTICE has been turned on
  • Fixed issue that logs would be always be saved to ‘uploads’

1.6.2

  • Improved memory usage.
  • Fixed a lot of fatal memory errors by avoiding loading file lists to memory
  • Exceptions are checked against the full file and path instead of against the path only
  • Fixed an error where getimagesize was called without first checking if the file existed
  • Improved code to find attachments from invalid files
  • Temporaly removed option to remove meta from valid meta data, will be returned in next version

1.6.1

  • Optimized code for major speed improvements
  • Optimized array indexes
  • A lot of minor fixes and improvements
  • Improved image table loading significantly
  • Added option to increase decrease number of images which are handled each step

1.6.0

  • Optimized wp_query by retrieving only ID instead of full attachment data
  • Fixed jQuery Ajax Setup interfering with other Ajax calls outside plugin

1.5.9

  • Added code to remove old indexes as we now work with only one index
  • Updated CSS to avoid wrapping in some columns

1.5.8

  • Fixed call by reference error in PHP 5.4+
  • Move/Restore and Delete file functionality now also possible by bulk or single entry

1.5.7

  • Added option box to skip images with part of string

1.5.6

  • More skipping code when the index is too large. This is very usefull for initial bulk repair/delete

1.5.5

  • Added pagination
  • Skipping search for images in scripts/plugins when the array is too large

1.5.4

  • Changed function to find image in files due to memory problems on some websites

1.5.3

  • Split up Ajax calls to avoid timeouts

1.5.2

  • Many small improvements

1.5.1

  • Removed searching for image filenames/paths in themes and plugins

1.5

  • Reduced memory footprint which caused timeouts on some systems

1.4

  • Fixed handling of unknown errors
  • Fixed error when image had no sizes in meta data

1.3

  • Fixed loading message not appearing in IE and Chrome

1.2

  • Fixed warning on main screen (thank you Taliwalt 😉

1.1

  • Increased information in debug.json log

1.0

  • Bulk repair/delete added
  • Code cleanup
  • Small improvements

0.9

  • Fixed issue where repairing ‘full’ sized metadata didnt work

0.8

  • Restore functionality was broken, fixed

0.7

  • Small updates

0.6

  • Logs renamed

0.5

  • Small bugfix

0.4

  • Major overhaul
  • Logs improved
  • Log tabs added for reviewing
  • More detailed indexing and results

0.3

  • Small bugfix concerning log location and removal

0.2

  • Added full logging

0.1

  • Initial release