How to Delete Unused Images from Your Magento Media Folder

How to Delete Unused Images from Your Magento Media Folder

Use the Hackathon EAV cleaner module for this. After installation you can use the command eav:media:remove-unused

Also you can do it by installing the module below and running these commands.

composer require ekouk/imagecleaner “dev-master”
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Run in check only mode which will report the number and size in Mb of unused images.

bin/magento ekouk:cleanimages
Then run this command to delete the files.

bin/magento ekouk:cleanimages -d

Al Mahbub Khan
Written by Al Mahbub Khan Full-Stack Developer & Adobe Certified Magento Developer

Full-stack developer at Scylla Technologies (USA), working remotely from Bangladesh. Adobe Certified Magento Developer.