Many web-stores with a long history run into a problem with the server's 'pub/media/' folder getting pumped and taking up plenty of precious storage space. Tens, even hundreds of gigabytes of data that take more and more despite the number of goods remains stable.
Having examined the contents of the media folder, we concluded it contains all ever uploaded images including those unusable by Magento. Real heaps of rubbish! And what surprised us even more was when we specially tested the process of removal of a product/category containing images as well as removal/editing of images under product's 'Images And Videos'. It appeared Magento only removes records about the images, not their physical files. This becomes one of the major causes for the website to occupy more space and to slow down a system call for files and images due to server's extreme file system load.
The extension we present allows you to thoroughly scan and safely clean the 'pub/media/' folder.
The procedure that the extension performs is not intended to be run only once, else the media folder will start growing again. This is why we specifically added a programmable cron job for the extension to scan the storage and automatically clean it once a week/month. To configure resources to clean and run a clean procedure manually, go to the extension's configuration page:
• Stores > Configuration > SAFEMAGE: Image Cleaning
1) Resources to clean are represented by the following options:
• Image files that do not belong to any product
• Image files that do not belong to any category
• DB record related to a product's nonexisting image file
• DB record related to a category's nonexisting image file
2) Based on capabilities of your server, specify the One-Time Limit for cleaning to make sure your system doesn't hang for a long time
3) Automatize the whole process by enabling and setting up a cron schedule
4) You can always make a manual clean run by hitting the 'Clean Now' button
The cleaning results are always logged in
- Safely cleans dead files in 'pub/media/' which may greatly reduce the folder's size
- Matches physical file against its record in the DB
- Removes product's and category's obsolete and unutilized images
- Removes media's DB records relating to nonexisting image files of products and categories
- Configurable cron schedule for cleaning
CompatibilityMagento Open Source (CE) 2.1.x, 2.2.x
Magento Commerce (EE) 2.1.x, 2.2.x
We provide comprehensive product support for all the Magento extensions available on this site starting from the moment of your purchasing them. If you need help on the extensions installation or on any issues relating to our products, our dedicated team of proven technical experts is at your service, ready to assist you at any time.
Changelognew feature bugfix
- v.2.0.1 (Mar 7, 2018)
- Addressed a ‘chdir: no such directory’ warning.
- v.2.0.0 (Feb 12, 2018)
- Initial release.