Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Install ImageClean extension
 
MikeDeveloper
Jr. Member
 
Total Posts:  1
Joined:  2013-03-05
 

Hi,

I\’m new in magento.
I want to install magento extension - ImageClean.
1 - I would like to know in what folder i install the extension.
2 - What do i do after i install the module?
3 - How do i set a cron job to the ImageClean?

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GoMageTeam
Guru
 
Avatar
Total Posts:  356
Joined:  2013-01-13
Warsaw, Poland
 

Hello,

At first you need to create imaclean.php file in the root Magento directory and write the following code there:

<?php
    
require_once "app/Mage.php";
    
umask (0);
    
Mage :: app("admin");

    
Mage::helper('imaclean')->compareList();
    
$collection Mage::getModel('imaclean/imaclean')->getCollection();

    foreach (
$collection as $image)
    
{
        
try {
            unlink(
'media/catalog/product'$image->getFilename());
            
$image->delete();
        
catch (Exception $e{
            Mage
::log($e->getMessage(),null,'imaclean.log');
        
}
    }
?>

After this action you should run the command in the console:

sudo crontab â€“e

And then you should write there:

0 0 * * * /usr/bin/php /full/path/to/imaclean.php

It will set up cron at 00 hours 00 minutes per every day, the other words the clearing of the images will be started at midnight.
Here is an important remark:
If you have many products, it will not work, it will be hanging.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiefair
Mentor
 
Avatar
Total Posts:  1848
Joined:  2009-06-04
 

@gomage - Can you modify that script so it skips over the placeholder images?

Otherwise, thank you for a really nice way to automate some housekeeping that Magento should have had built in from the beginning!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top