Magento product images can remain on the server after they are removed
from product galleries. Over time, these orphan files can consume
significant storage inside
pub/media/catalog/product.
This CLI tool finds files that are no longer referenced by Magento's
media gallery table and lets you review them before permanently
removing them.
CLI cleanupPreview before deleteConfirmation requiredMB + file count
At a glance
Find the product images Magento no longer uses
The module compares files on disk with Magento's catalog media gallery
records. Files that are no longer referenced can be identified and
removed from the filesystem through Magento CLI.
Recover storage
Find leftover product image files occupying space in
pub/media/catalog/product.
See what will be removed
Run the mock command first and review the paths before performing
a live cleanup.
Protect referenced images
Files still referenced by Magento's media gallery remain in place.
Run from CLI
Designed for administrators and developers working through
SSH and Magento CLI.
The command
Mock first. Flush when the list looks right.
The mock mode shows the files that would be removed without
deleting them. When you are satisfied with the result, run the
same command without --run-mock.
The command also reports the number of files and the amount of
unused storage identified.
The important distinction is between a file that exists on the
filesystem and a file that Magento still knows about. This tool is
designed to identify the former when it is no longer represented
by Magento's product media gallery data.
Magento still references the image
If the image has a corresponding record in
catalog_product_entity_media_gallery,
it is treated as referenced and remains on disk.
Magento no longer references the file
If a file exists under
pub/media/catalog/product
but has no corresponding gallery record, it can be identified
as an orphan file for cleanup.
Cache copies remain protected
Files matching referenced product media are kept, including
cache copies associated with those images.
What stays / what goes
Know exactly what the cleanup is looking for
Kept
Files that match values referenced by
catalog_product_entity_media_gallery,
including cache copies of referenced product images.
Flushed
Orphan files under
pub/media/catalog/product
that no longer have a corresponding gallery record.
Reported
File paths are written to the terminal, together with a summary
showing the number of files and unused size in MB.
No Admin UI
This is a server-side Magento CLI cleanup tool. It is intended
for SSH, deployment, maintenance, and administrator workflows.
Use it / leave it
Designed for filesystem cleanup — not product editing
Use it when
Your media directory contains years of leftover files
Product images have been replaced or removed over the years.
Catalog imports have created files that are no longer needed.
The size of pub/media keeps growing.
Backups are becoming larger because of accumulated media files.
You want to preview the cleanup before deleting anything.
Do not use it when
You are trying to manage normal product gallery images
You have no filesystem or media backup.
You want to delete images belonging to one specific SKU
from the Magento Admin.
A CDN or another server depends on media that Magento's
database does not know about.
You have not reviewed the mock output before running a
live flush.
Back up your media first.
A live flush permanently deletes files from the filesystem.
The module does not provide a recycle bin or restore function.
Run the mock command, review the output, and make sure your
backup is available before performing a live cleanup.
Go live safely
Five steps from preview to cleanup
1Install
Install Emmo_FlushImages, enable the module, and run
setup:upgrade.
2Back up
Copy pub/media/catalog/product or take an appropriate
server/filesystem backup.
3Mock
Run the mock command and inspect the files that would be
removed.
4Flush
Run the same command without --run-mock and confirm
the operation at the prompt.
5Check
Open several products, confirm their gallery images still
render, and review the reported storage amount.
Customer experience
Real-world cleanup can add up quickly
“Removed more than 120GB”
Customer review describing the removal of more than 120 GB from
a catalog images directory that had grown beyond 500 GB.
Actual results depend on how many unreferenced files exist in
your Magento installation.
Before you run it
Common questions
Does it delete images that are still used by products?
The cleanup checks Magento's media gallery data and keeps files
that are still referenced there. Always run the mock command
and review the output before a live flush.
Can I preview the files before deleting them?
Yes. Use
--run-mock.
Mock mode reports the paths that would be removed without
performing the deletion.
Does it have an Admin interface?
No. The module is operated through Magento CLI over SSH.
There is no Admin button for deleting unused product images.
Can it restore deleted files?
No. A live cleanup permanently removes files from the
filesystem. Maintain an appropriate backup before running it.
Is this the same as deleting a product image from Admin?
No. Product gallery management is handled through Magento
Admin. This tool is intended to find filesystem files that
Magento's media gallery no longer references.
What directory does it clean?
The cleanup targets product media under
pub/media/catalog/product.
What you get
Compatibility
Magento Open Source & Adobe Commerce
PHP 8.1–8.3
CLI / SSH
catalog/product media
Installation
Package path —
unzip as
app/code/Emmo/FlushImages,
enable the module, and run setup:upgrade.
Command —
emmo:images:flush-unused [--run-mock]
Not included
No Admin button, no recycle bin, and no
“delete this product's images” interface.
This tool is specifically for identifying and removing
product media files that Magento's media gallery table
no longer references.
Clean up accumulated product media with a
preview-first CLI workflow.
Mock the list, review it, back up your media, then flush.
Support:
[email protected]
More Information
More Information
Follow Meta Tag
Please Select
Reviews
Zoe
Overall Rating
100%
Excellent Extension
Revamped my store by clearing out loads of unused product images. The support team swiftly tackled an installation hiccup. Thumbs up
Clarke
Overall Rating
100%
unique extension
Absolutely unique extension! It's the first of its kind that I've come across. Incredibly useful—I'm excited to use it, I wasted plenty of money buying additional space on server! but, now it allowed me to empty the media folder from unwanted images. Awesome, thanks EMMO team.
Grace
Overall Rating
100%
This extension is a lifesaver!
This extension is a lifesaver! It effortlessly removes unwanted images, boosting my store's performance. Installing it was easy, and it worked like a charm right out of the box, so no need to reach out to support. Highly recommended
Emma Martinez
Overall Rating
100%
a real time-saver
Handling our website's media is now super easy! This tool is a real time-saver, streamlining the backend tasks effortlessly
Geidu
Overall Rating
100%
A reliable module that works just as needed
Great product and great support, highly recommended
Myra
Overall Rating
100%
Fixed my media directory
My media directory was messed up! this saved my life. The extension is good and the support is quick and efficient.
Powel
Overall Rating
100%
Removed more than 120GB
Our catalog images directory was huge and more than 500GB was used by images only. We were able to remove more than 120GB with this extension. Support was really quick to guide us on it's usage