Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
Hi Kenny
Could you provide the code you're currently working on?
/Jan
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.
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
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
We have now reported this as a bug:
http://issues.umbraco.org/issue/U4-6551
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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
Hi Kenny
Could you provide the code you're currently working on?
/Jan
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
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
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
We have now reported this as a bug:
http://issues.umbraco.org/issue/U4-6551
is working on a reply...