Magento 2 Image Clean

 

Magento 2 Image Clean extension lets you remove the used and unused product images and unused category images from media folder of the Magento 2 store.

 

Table of Content

  1. Extension Installation Guide
  2. Configuration
  3. Unused Category Images Cleanup
  4. Used Product Images Cleanup
  5. Unused Product Images Cleanup
  6. Image Cleanup Using SSH Commands

 

  1. Extension Installation
  • For Magento Marketplace Customers
    • Login to your SSH and run:
      • composer require meetanshi/magento-2-unused-image-cleaner
    • Enter your authentication keys. Your public key is your username; your private key is your password.
    • Wait for Composer to finish updating your project dependencies and make sure there aren’t any errors.
    • To verify that the extension is installed properly, run the command:
      • php bin/magento module:status Meetanshi_ImageClean
    • By default, the extension is probably disabled. Enable the extension and clear static view files:
      • php bin/magento module:enable Meetanshi_ImageClean --clear-static-content
      • php bin/magento setup:upgrade
      • For Magento version 2.0.x to 2.1.x - php bin/magento setup:static-content:deploy
      • For Magento version 2.2.x & above - php bin/magento setup:static-content:deploy –f
      • php bin/magento cache:flush
  • For Meetanshi Customers
  • Extract the zip folder and upload our extension to the root of your Magento 2 directory via FTP.
  • Login to your SSH and run below commands step by step:
  • php bin/magento setup:upgrade
  • For Magento version 2.0.x to 2.1.x - php bin/magento setup:static-content:deploy
  • For Magento version 2.2.x & above - php bin/magento setup:static-content:deploy –f
  • php bin/magento cache:flush

 

  1. Configuration
    For configuring the extension, login to Magento 2, move to Stores > Configuration > Image Clean where you can find various settings to enable the extension.
  • Clean Resources: Select the resources to delete in case of both the manual and periodic cleanup.
  • Maximum Images to Process in Each Attempt: Enter the number of images to process in each attempt.
  • Manual Clean Up: Click the button to clean up the selected resources manually.
  • Schedule Periodic Clean Up: Select YES to schedule periodic cleanup on a regular basis.
  • Clean Up Frequency: Set frequency for the periodic cleanup.
  • Start Time: Define start time for the periodic clean up to start image clean up on the scheduled frequency.


 

  1. Unused Category Images Cleanup
    Apart from the manual and periodic cleanup, the extension enables to delete the unused category images from Image Clean > Unused Category Images. Click “Update Image List” button to update the list of unused category images. After updating the image list, all the unused category images get listed along with the details like image, path, and size. These images can be deleted using mass delete action or individually using delete action.



 

  1. Used Product Images Cleanup
    Apart from the manual and periodic cleanup, the extension allows to update the list of product images in use and delete them from Image Clean > Used Product Images. On click of “Update Image List” button, used images from product media get fetched and listed in the grid along with details like product name, product image, image path and size. These images can be deleted after selection using mass delete action. Also, you can delete individual image using delete action.

    If you have recently disabled some store products and will no longer enable it, you can use this feature to remove product images in use.


  

  1. Unused Product Images Cleanup
    Apart from the manual and periodic cleanup, the extension allows to update the list of unused product images and delete them from Image Clean > Unused Product Images. On click of “Update Image List” button, unused images from product media get fetched and listed in the grid along with the details like image, path and size. These images can be deleted after selection using mass delete action. Also, you can delete individual images using delete action.


 

  • Success Message
    Once the selected images are deleted, the success message to acknowledge the delete action is displayed as shown below.



 

  

  1. Using SSH Commands for Image Cleanup
    Apart from using manual clean up, you can use SSH commands to perform each cleanup action. When you have tons of products and hundreds of categories, using the manual cleanup may cause the process timeout. With SSH commands, you can sit back and let automation perform the action without worrying about the process timeout.
  • php bin/magento imageclean:product-unused-image:fetch - To fetch unused product images.
  • php bin/magento imageclean:product-used-image:fetch - To fetch used product images.
  • php bin/magento imageclean:category-image:fetch - To fetch unused images of categories.
  • php bin/magento imageclean:product-used-image:clean - To clean used product images.
  • php bin/magento imageclean:product-image:clean - To clean unused product images.
  • php bin/magento imageclean:category-image:clean - To clean unused images of categories.