Copied to clipboard

Flag this post as spam?

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


  • Kenny Burns 165 posts 285 karma points
    Apr 23, 2015 @ 15:42
    Kenny Burns
    0

    GetMediaByPath

    Hello,

    Version 7.2.2 - I am trying to retrive a media item from the actual path using the MediaService GetMediaByPath(string) - i'm passing in "/media/1028/test.jpg" which definately exists and is definately the value for the umbracoFile property.

    However, it keeps returning null. Does this work?

    Thanks,

    Kenny

  • Jan Skovgaard 11241 posts 23387 karma points MVP 6x admin c-trib
    Apr 23, 2015 @ 15:48
    Jan Skovgaard
    0

    Hi Kenny

    Could you provide the code you're currently working on?

    /Jan

  • Kenny Burns 165 posts 285 karma points
    Apr 23, 2015 @ 16:05
    Kenny Burns
    0

    Hi Jan,

    Basically, I am trying to get an image id from a path in a helper - really all I am doing is:

    var ms = ApplicationContext.Current.Services.MediaService;
    IMedia mediaItem = ms.GetMediaByPath("/media/1028/img2.jpg");

    Which should give me back a media item - but it doesn't - I have tried changing it to various different image url's but still no joy.

    Thanks,

    Kenny

  • Kenny Burns 165 posts 285 karma points
    Apr 23, 2015 @ 16:11
    Kenny Burns
    0

    And i assume its running off this function, which I can't see anything obviously wrong with, although I can't see what's going on with teh SQL.

    https://github.com/umbraco/Umbraco-CMS/blob/aa3c1d645b9a7e9d9e164403bd260f0fc7f11bb1/src/Umbraco.Core/Services/MediaService.cs#L568

    Kenny 

  • Tom Madden 205 posts 272 karma points c-trib
    Apr 24, 2015 @ 10:37
    Tom Madden
    0

    Richard,

    I tried it in 7.2.4 and got the same result as you, mediaitem was null, so I think you shoudl report it.

    t

  • Richard Terris 273 posts 714 karma points
    Apr 24, 2015 @ 10:38
    Richard Terris
    101

    We have now reported this as a bug:

    http://issues.umbraco.org/issue/U4-6551

Please Sign in or register to post replies

Write your reply to:

Draft