Copied to clipboard

Flag this post as spam?

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


  • jonok 260 posts 476 karma points
    Jul 18, 2013 @ 04:50
    jonok
    0

    Umbraco V6 - How to use the MediaService.Saved event?

    I'm trying to resize an image after it has been uploaded to the Media section, using the MediaService.Saved event. The EventHandler method for this event has a parameter Umbraco.Core.Events.SaveEventArgs<IMedia> - how do I find the uploaded media item within this collection of IMedia objects? I can loop through the SavedEntities (see below) but I'm not sure how to use it correctly?

    public MyClass()
    {
    MediaService.Saved += SavedEventHandler;
    }

    private void SavedEventHandler(IMediaService sender, Umbraco.Core.Events.SaveEventArgs<IMedia> e)
    {
    IEnumerable<IMedia> items = e.SavedEntities;
    foreach (IMedia item in items)
    {
    //code goes here?
    }
    }

     

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Jul 18, 2013 @ 12:08
    Jeroen Breuer
    0

    I think that it's the same as this little discussion on Twitter: https://twitter.com/kipusoep/status/355674279817379841

    "cause it might be a collection when using bulk save, so instead of having two signatures we opted for one."

    So if you only have 1 upload just grab the first one.

    Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies