Copied to clipboard

Flag this post as spam?

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


  • Diogo 2 posts 72 karma points
    Mar 15, 2016 @ 15:33
    Diogo
    0

    MediaService.GetMediaByPath always returns null on HttpApplication events

    Hi, I'm currently in need to get a media item by its url. The funcion provided in the MediaService always returns null no matter what, while if I get an item by its ID it's perfectly fine.

    My code is running on an HttpApplication event, more precisely the PreSendRequestHeaders

    Sample code:

                    IMedia media = ApplicationContext.Current.Services.MediaService.GetMediaByPath(app.Request.Url.AbsolutePath);
    
  • Marc Goodson 2149 posts 14377 karma points MVP 9x c-trib
    Mar 16, 2016 @ 11:52
    Marc Goodson
    0

    Hi Diogo

    This is a bug with Umbraco:

    issues.umbraco.org/issue/U4-6551

    The code in the core queries the Umbraco database umbracoFile property for an item matching the path of the media - but it looks like to me the functionality relies on only the path of the image being stored in the UmbracoFile property, and I think this has changed recently if you are using the cropper to be a JSON object including the path, but also crop information etc...

  • Diogo 2 posts 72 karma points
    Mar 16, 2016 @ 12:21
    Diogo
    0

    Hello Marc, after I published this topic I actually went searching for what was happening and I came to this particular conclusion.

    Is there any ETA for when this is getting fixed? Or a workaround I can use fairly soon?

Please Sign in or register to post replies

Write your reply to:

Draft