{"id":2482,"date":"2024-12-31T20:22:33","date_gmt":"2024-12-31T20:22:33","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/how-to-remove-unused-images-in-magento-2\/"},"modified":"2025-01-02T09:59:37","modified_gmt":"2025-01-02T09:59:37","slug":"remove-delete-unused-images-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/remove-delete-unused-images-in-magento-2\/","title":{"rendered":"How to Remove Unused Images in Magento 2?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2 image cleanup is essential for performance optimization. Because deleting a product or page in the platform does not remove its associated images from the server. And it can clog up the hosting server\u2019s disk space over time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Removing these unused images in Magento 2 helps free the disk space and enhance the performance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, you\u2019ll learn how to remove unused product images in Magento 2 and how to schedule automatic cleanups.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"why-clean\">Why Clean Unused Images in Magento 2?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here are a few reasons you should regularly clean unused images in Magento 2:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Optimize the hosting storage space<\/li>\n\n\n\n<li>Improve the server performance<\/li>\n\n\n\n<li>Enhance Magento site management<\/li>\n\n\n\n<li>Reduce Magento 2 store backup size<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Cleaning unused images in Magento 2 is a good practice overall. It can help you with many benefits, like optimizing your Magento 2 server storage and performance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"method-remove\">Method to Remove Unused Images in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The image clean extension for Magento 2 by Meetanshi helps you identify and remove unused images. It is approved by Adobe Marketplace and also supports auto-cleaning on a schedule.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step1\">Step 1: Install Magento 2 Image Clean Extension<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Go to\u00a0<a href=\"https:\/\/meetanshi.com\/magento-2-image-clean.html\">Magento 2 Image Clean<\/a>\u00a0by Meetanshi and download the extension for your store.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/03\/1-install-magento-2-image-clean-extension.png\" alt=\"Magento 2 Image Clean Extension by Meetanshi\" class=\"wp-image-45063\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Extract the downloaded zip file and upload it to your Magento 2 root directory via FTP.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Log into your Magento 2 SSH and run the following commands one by one to install the extension:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>php bin\/magento setup:upgrade<\/code><\/li>\n\n\n\n<li><code>php bin\/magento setup:static-content:deploy \u2013f<\/code><\/li>\n\n\n\n<li><code>php bin\/magento cache:flush<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The Magento 2 Image Clean extension will be successfully added to your store.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step2\">Step 2: Perform a Bulk Image Clean<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Image Clean extension by Meetanshi helps you identify and remove unused images in your store. The&nbsp;<strong>Configuration &gt; Unused Product Images<\/strong>&nbsp;and&nbsp;<strong>Configuration &gt; Unused Category Images<\/strong>&nbsp;grids provide a list of unused images in products and categories that you can manually clean.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also bulk-clean the unused product images in Magento 2 from the extension configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Log into your Magento 2 admin panel and navigate to&nbsp;<strong>Image Clean &gt; Configuration<\/strong>&nbsp;in the left menu.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/03\/2-go-to-configuration.png\" alt=\"Go to Image Clean Configuration in Magento 2\" class=\"wp-image-45064\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">In the&nbsp;<strong>Image Clean Configuration<\/strong>, choose the resources you want to clean. You can select from:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unused Category Images<\/li>\n\n\n\n<li>Unused Product Images<\/li>\n\n\n\n<li>Database Record for Non-existing Product Images<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Set the maximum number of images you want to process in each clean (e.g., 10,000) and click \u201c<strong>Clean Now<\/strong>.\u201d<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/03\/3-remove-unused-images-in-magento-2.png\" alt=\"Remove unused images in Magento 2\" class=\"wp-image-45065\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">It will clean the selected Magento 2 resources and remove unused images from products, categories, and databases. You can verify the results by checking the number of unused images in Magento 2 from the&nbsp;<strong>Image Clean &gt; Unused Product Images<\/strong>&nbsp;and&nbsp;<strong>Image Clean &gt; Unused Category Images<\/strong>&nbsp;grids.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step3\">Step 3: Schedule Automatic Image Clean in Magento 2<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The extension allows you to automatically remove unused product images in Magento 2 on a schedule. It helps you keep your store clean and storage optimized.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set&nbsp;<strong>Schedule Periodic Clean Up<\/strong>&nbsp;to \u201c<strong>Yes<\/strong>\u201d and select the cleanup frequency from:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Daily<\/li>\n\n\n\n<li>Weekly<\/li>\n\n\n\n<li>Monthly<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Set the start time for the Magento 2 image clean process.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/03\/4-magento-2-image-clean-on-a-schedule.png\" alt=\"Magento 2 Image Clean on a Schedule\" class=\"wp-image-45066\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Click the \u201c<strong>Save<\/strong>\u201d button on the top right.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, the extension will run scheduled image cleanups in Magento 2 as configured on a cron job. This is helpful for keeping your Magento 2 storage clean and optimizing it for performance. The best part is that it requires only a onetime setup and helps you save time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><div class=\"meetanshi-cta\">\r\n<div class=\"cta-content-wrapper\">\r\n<span>Magento 2 Image Clean<\/span>\r\n<p>Clear up space and remove unused product and category images from the media folder in a few minutes.<\/p>\r\n<a href=\"https:\/\/meetanshi.com\/magento-2-image-clean.html\" target=\"_blank\" class=\"btn-primary\">Clear Now <\/a>\r\n<\/div>\r\n<div class=\"cta-image-new\">\r\n<img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2025\/11\/image-clean.png\" alt=\"Magento 2 Image Clean\">\r\n<\/div>\r\n<\/div><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"for-developers\">For Developers: Commands to Find &amp; Remove Unused Images in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Magento 2 Image Clean extension also lets you perform operations programmatically. Developers can use the following SSH commands to clean Magento 2 images:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Image Clean Task<\/th><th>SSH Command<\/th><\/tr><tr><td>Find all the unused product images in Magento 2<\/td><td><code>php bin\/magento imageclean:product-unused-image:fetch<\/code><\/td><\/tr><tr><td>Find all the unused category images in Magento 2<\/td><td><code>php bin\/magento imageclean:category-image:fetch<\/code><\/td><\/tr><tr><td>Remove all the unused product images in Magento 2<\/td><td><code>php bin\/magento imageclean:product-image:clean<\/code><\/td><\/tr><tr><td>Remove all the unused category images in Magento 2<\/td><td><code>php bin\/magento imageclean:category-image:clean<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The Magento 2 Image Clean extension by Meetanshi is the simplest way to find and remove unused images in your store. The extension supports image clean-up automatically on a schedule to prevent your hosting server from running out of storage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2 image cleanup is essential for performance optimization. Because deleting a product or page in the platform does not remove its associated images from&#8230;<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2482","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2482"}],"version-history":[{"count":1,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2482\/revisions"}],"predecessor-version":[{"id":3922,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2482\/revisions\/3922"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}