Vai al contenuto

Orphan images: cleaning media/ without deleting the wrong one

Since 26.7 Media Cleaner finds the files no product or content uses any more, shows a preview and deletes them, with exclusions.

A store that changes its catalog collects images. Someone uploads a photo, changes it, uploads another, and the first one stays in media/ forever: no product uses it, no page mentions it, and still it takes disk space and ends up in every backup. Since 26.7 the core ships Media Cleaner, born as the Fballiano_ImageCleaner module and rebuilt with Maho conventions: it finds unreferenced files, shows them and removes them.

Where it lives

System > Tools > Media Cleaner. The page works in two beats: the scan first, the choice after. There is no automatic deletion, and that is the right call: a file can look useless and still be used somewhere the scan does not read.

The scan

Press Scan and the page works in the background, showing progress. The result is a grid with type, file name, a thumbnail preview and the actions for the single row. A scan can end with errors on some files: the count says so, and stays visible until you press Reset Results and start again.

🧹 Cleaning note: a full scan on a large catalog takes time. Run it in a quiet hour, not while the store is uploading images.

What the scan knows, and what it cannot

The criterion is the reference: a file that no product, category, CMS page, block or blog post mentions is reported. Your theme, a CSS file, an image pulled in by a script or by content that comes from an extension are not part of the count.

That is where the setting that matters comes in, Files/folders blacklist. One path per line, relative to media, wildcards allowed:

wysiwyg/landing*/*.jpg
wysiwyg/images2021
brand/cataloghi-*

Whatever matches is never identified and never deleted. It is the safety net for the folders the store uses for something else: campaign banners, PDF catalogs, images uploaded by hand over FTP.

🧹 Cleaning note: the blacklist is written before the first scan, not after seeing the grid. Reading a list of files and adding them one by one afterwards is the slowest way to do the same thing.

How deletion works

Rows can be deleted one at a time or as a multiple selection, and the grid exports to CSV or Excel for a check before going ahead. Deletion is permanent: the file leaves media/.

That is why the sensible sequence is always the same: blacklist, scan, export, review the list, delete.

🧹 Cleaning note: before deleting, take a backup of media/ or at least make sure a recent automatic backup exists. The cleaner has no bin, and it is not meant to have one.

The other folders that fill up

The same page carries actions to empty the service folders: temporary media files, the import folder and the export one. They are the leftovers nobody watches, and they grow with every product or order export.

The settings

Under System > Configuration > General > Media Cleaner, besides the blacklist:

Setting What it does
Thumbnail size size of the preview thumbnails in the grid
Enable click on preview image to zoom it opens the full image on click, useful to recognise a file by its content and not its name

🧹 Cleaning note: a file uploaded from the warehouse is often called IMG_2831.JPG. The zoom is what keeps you from deleting the photo of a product still on sale.

A habit, not an event

Cleaning works when it becomes periodic: one scan a month, a blacklist update whenever a new campaign starts, and a look at the export before deleting. Tuned like that, Media Cleaner keeps media/ in check without ever becoming the day you find out what went missing.

Text prepared with the help of AI and checked against the source before publication. It can still contain mistakes: if you find one, report it.Read the manifesto

Does your store still sell?

Tell us where you are starting from: we reply with a first assessment, no strings attached.

Ask for the store assessment