(The following is for Optimizely CMS 11).
We have an initialization module in place that registers an event handler for the ContentChanged
event that is raised by the CMS. This is already being used successfully - one usage of this is to evict cached data when pages are published.
Now we need to detect when an image is uploaded so we can automatically generate derived images from it.
However, the ContentChanged
event does not get raised when uploading an image.
It gets raised when renaming it, or moving it to another folder, or moving it to the wastebasket but the initial uploading doesn't trigger it...
I've consulted colleagues, done some digging in the documentation, the Epi forums and of course google but found nothing.
Documentation implies that media items, when they are uploaded, are automatically published by default (and says elsewhere you can change this behaviour - but doesn't say how). If this is the case, then it must be a different kind of publish because publishing anything else raises the event, but uploading an image doesn't.
Has anyone found a way to programmatically detect when a media item is uploaded?
It seems this is possible.
Previously we have been using an IInitializableModule and the event handler was not invoked with the following:
ExtendedContentEvents.Instance.ContentChanged += HandleChangedContent;
However, it did work with:
var contentEvents = context.Locate.ContentEvents();
contentEvents.PublishingContent += HandleChangedContent;