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 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
- Upload Image Cleanup to the ‘/wp-content/plugins/’ directory
- Activate the plugin through the ‘Plugins’ menu in WordPress
- Go to the administration page: Tools > Image Cleanup
- Initiate index images
- Check log tabs for detailed information
- Choose to move files to temp location
- Restore or delete files from temp location
- Clutter free content folder! 😉
- 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!
In the last few days I’ve tried every image clean-up plugin I could find here in the repository. The site I’m working on has many thousands of images and Image Cleanup is the only one I could get to work. At least it works most of the time. Sometimes I do get ‘out of memory’ errors, but by using the inbuilt filter to scan only some sub-directories I’ve been able to work around the problem.
I’ve been able to delete over 20,000 unused images so far.
It’s a shame the plugin seems to no longer be supported.
Complains about PHP version. Says 5.1 is required. I have PHP 7.
We’ve installed this plugin on a multisite hoping it would get rid of the unused images. Upon using Image Cleanup, it is like a hurricane when through our website and destroyed nearly all the thumbnails and previews from the backend. Also images which were in use got deleted and caused a bigger mess. It is the second day since we’ve started fixing things up. Don’t go through this pain!
This plugin did what it says it would do, and even accurately discovered images in custom fields.
Made a huge mess of my client’s site. Many images the plugin marked as unreferenced and unused were in fact used.
Thankfully, I had a complete backup created with Duplicator Pro to fall back on. Restoring the site from the backup was the only way to put the site back together again.
The documentation for this plugin is almost non-existent and the plugin hasn’t been touched for over two years. Red alert!
About all I can say is use extreme caution and have a complete backup before proceeding.
I’ve uninstalled this plugin and put it on my “do not use” list.
Selbst mit der aktuellen 4.4 WordPress Version läuft dieses Plugin immer noch Problemlos und entfernt zuverlässig die riesigen Original-Bilddateien.
Contributors & Developers
“Image Cleanup” is open source software. The following people have contributed to this plugin.Contributors
- Fixed error where meta data could not be removed, thanks Squill1959
- 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)
- Fixed error on invalid metadata
- Added check if meta image path was set
- 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
- Added quickview of image by clicking on filename
- Adjusted options save method
- Added setting to choose how many posts should be processed each step
- Fixed general actions not showing up
- Fixed posts not being scanned
- Broke up post scanning in multiple ajax calls
- Fixed UTF8 basename bug (PHP bug)
- Improved comparision functions
- Added additional debug information
- Fixed debug log link not working
- Fixed error handling when image dimensions could not be read
- Small bugfix which prevented ajax loops on some platforms
- Small bugfix to check if meta size is available
- 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’
- 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
- 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
- Optimized wp_query by retrieving only ID instead of full attachment data
- Fixed jQuery Ajax Setup interfering with other Ajax calls outside plugin
- Added code to remove old indexes as we now work with only one index
- Updated CSS to avoid wrapping in some columns
- Fixed call by reference error in PHP 5.4+
- Move/Restore and Delete file functionality now also possible by bulk or single entry
- Added option box to skip images with part of string
- More skipping code when the index is too large. This is very usefull for initial bulk repair/delete
- Added pagination
- Skipping search for images in scripts/plugins when the array is too large
- Changed function to find image in files due to memory problems on some websites
- Split up Ajax calls to avoid timeouts
- Many small improvements
- Removed searching for image filenames/paths in themes and plugins
- Reduced memory footprint which caused timeouts on some systems
- Fixed handling of unknown errors
- Fixed error when image had no sizes in meta data
- Fixed loading message not appearing in IE and Chrome
- Fixed warning on main screen (thank you Taliwalt 😉
- Increased information in debug.json log
- Bulk repair/delete added
- Code cleanup
- Small improvements
- Fixed issue where repairing ‘full’ sized metadata didnt work
- Restore functionality was broken, fixed
- Small updates
- Logs renamed
- Small bugfix
- Major overhaul
- Logs improved
- Log tabs added for reviewing
- More detailed indexing and results
- Small bugfix concerning log location and removal
- Added full logging
- Initial release