Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Björn 18 posts 158 karma points
    Mar 19, 2018 @ 08:16
    Björn
    0

    Mediaservice delete event

    Hi. I'm trying to hook into the delete media event and it works fine when I delete files and folders which are inside the recycle bin, but when I click on the recycle bin and chooses "Empty recycle bin" the event is not triggered. Anyone knows why that is?

    /Björn

            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            MediaService.Saved += MediaServiceSaved;
            MediaService.Deleted += MediaServiceDeleted;            
        }
    
        void MediaServiceDeleted(IMediaService sender, DeleteEventArgs<IMedia> e)
        {
            foreach (var mediaItem in e.DeletedEntities)
            {
                System.Diagnostics.Debug.WriteLine("Deleting object");
            }
        }
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Mar 19, 2018 @ 08:23
    Dave Woestenborghs
    0

    Hi Björn

    You need to hook in to the EmptiedRecycleBin or EmptyingRecycleBin events of the Mediaservice.

    See : https://our.umbraco.org/apidocs/csharp/api/Umbraco.Core.Services.MediaService.html

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft