3

I'm trying to trigger a function after an image has been uploaded using the wysiwyg editor but I don't think an events is fired after this operation. I know it's relatively easy to do so when you upload product images to the catalog but not so much when adding images to cms pages or static blocks.

I think the uploadFile function in the Mage_Cms_Model_Wysiwyg_Images_Storage class is responsible for this so I guess I could override it in my module but I was wondering if there was a cleaner way to do it.

2

Following these instructions I was able to log all the events that fire when you upload an image in the cms pages but sadly there is none that let's you hook into specifically to handle the uploaded image.

The closes one I found was controller_action_predispatch_adminhtml_cms_wysiwyg_images_thumbnail and controller_action_postdispatch_adminhtml_cms_wysiwyg_images_thumbnail but these run when the thumbnails in the image upload modal are rendered.

I guess overriding the Mage_Cms_Model_Wysiwyg_Images_Storage class is the way to go here.

  • Just wanted to mention that in Magento 2 the event catalog_product_gallery_upload_image_after can be used. – Daan van den Bergh Apr 17 '18 at 13:53
0

There are custom events tied to model classes, check if one of those can be used in your case. They are caled something_load_after, something_load_before, something_save_after and something_save_before. Like model_save_before but for specific classes. This is a complete set of events you should check.

  • I did go through that very same list but couldn't find anything related to the upload functionality. – Javier Villanueva Jan 19 '15 at 0:31
  • As I told you, there is no event attached to the upload functionality but you can use a model class related to that particular model. Also check the code to see if there is any event dispatched at any point when uploading the image. – mbalparda Jan 19 '15 at 11:28
  • Sadly I haven't been able to find any event, I'll leave this question open in case someone has an idea. – Javier Villanueva Jan 25 '15 at 3:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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