Event Observer – Hook into Image Upload Function on WYSIWYG Editor

event-observerimage-uploadoverridesuploadwysiwyg

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.

Best Answer

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.

Related Topic