Admin users can replace asset files without having to deal with re-uploading/re-creating a new asset using the feature/technique described in Peter's answer here: Is it possible to replace uploaded assets?. This has the advantage of preserving any values in the asset's custom fields.
I need to populate some of those fields dynamically though, so they correspond to the new file for the asset. So, I wrote a small plugin that listens to the assets.onReplaceFile event like so:
craft()->on('assets.replaceFile', function(Event $event) {
Craft::dd($event->params); // or whatever
});
But the code in the handler never gets executed. Is this the right event to listen to this specific user action or is there another event for it? Or am I doing something wrong here? Thanks!
init()
method?init()
method of the plugin's main class.