How to Upgrade Magento 2 Version: A Complete Step-by-Step Guide
A step-by-step guide to upgrading your store to the latest Magento 2 release, and why running an old version costs you.
Where orphaned product and category images come from in Magento 2, how to find them safely, and what to check before you delete anything.

Every time a product is deleted, an image is replaced, or a catalog is re-imported, Magento 2 can leave the old image files behind in pub/media/catalog/product. Nothing references them any more, but they stay on disk, take up space, and make backups and deployments slower. This guide explains where the leftovers come from, how to find them safely, and what to check before you delete anything.
Magento stores product images as files under pub/media/catalog/product and records which file belongs to which product in its media gallery tables. Deleting a product or removing an image from the gallery removes the record, but not always the file. Common sources of orphaned files are:
Over years of catalog changes, a store can collect a large number of these files.
Not every file Magento doesn't list in the gallery is safe to remove. Leave these alone:
pub/media/catalog/product/cache: resized copies Magento creates for the storefront. Clear them with Flush Catalog Images Cache in System > Cache Management (and regenerate them with php bin/magento catalog:images:resize), not by hand.The reliable method is to compare the files on disk with the images Magento actually uses:
pub/media/catalog/product, skipping the cache, watermark and placeholder folders.catalog_product_entity_media_gallery and catalog_product_entity_media_gallery_value), not just the base images.pub/media/catalog/category against each category's image.You can script this yourself, or use our Image Cleaner for Magento 2, which does the comparison from the admin: click Load Unused Images and review the list, with a thumbnail and path for each file.
Deleting a file from disk is permanent. Before any cleanup:
pub/media, or at least the catalog folders.Image Cleaner never deletes anything by itself: you select the files to remove, one at a time or with a mass action. The user guide covers each step and the known limitations, such as remote (S3) media storage not being scanned.
There is no fixed rule. A sensible time is after a large import, a catalog restructure, or a product range change, and before a migration, when a smaller media folder makes the move faster.
The same problem exists on Magento 1.9, in media/catalog/product. Image Cleaner for Magento 1 lists unused product and category images, exports the list to CSV, and lets you delete them from the admin.
If your media folder is part of a bigger performance or hosting problem, tell us about your store and we will look at the whole picture.
More guides from the Magexweb blog.
A step-by-step guide to upgrading your store to the latest Magento 2 release, and why running an old version costs you.
Why patching on time matters, and how to install Magento 2 security patches with Composer or by hand.
Shipping costs are a common reason shoppers abandon a cart. Here’s how a free shipping bar nudges them to add one more item instead.
Upgrades, security patches and platform moves are what we do every day. Tell us what your site needs, and we will reply with questions and next steps.
0 Comments
No comments yet. Be the first to comment.
Leave a Comment
Please sign in to comment. Sign in