0

I've created a Magento module which should hook into an event when a file is saved to cache. But it looks like there isn't any event like that, or am I missing something?

I currently hooked up with the

category_product_gallery_upload_image_after

but then the file is edited by magento before writing to cache because it's resized. Therefor overwriting my file optimalisation.

Is there any way I can hook to an image before it's written to cache, or after the resizing?

1 Answer 1

1

There is no native function or event for this.

But you can done by rewrite the image save function Mage_Catalog_Model_Product_Image::save file()

i.e.,

public function saveFile() { 
   $filename = $this->getNewFile();
   $this->getImageProcessor()->save($filename); 
   //you can do your logic here.
    Mage::helper('core/file_storage_database')->saveFile($filename);
    return $this; 
}
2
  • That is the place when it's saved to the cache?
    – Niels
    Commented Aug 2, 2015 at 11:55
  • Yes, to resize product image we have use following code Mage::helper('catalog/image')->init($product,'image')->resize(500). So in this function they have save the image using above function. Commented Aug 2, 2015 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.