try
{
IMedia media = MediaManager.GetMediaFileById(Id);
var umbracoFile = media.GetValue<string>(Constants.Conventions.Media.File);
return JsonConvert.DeserializeObject<ImageCropDataSet>(umbracoFile).Src;
}
catch(Exception e)
{
return string.Empty;
}
You're probably missing a few namespaces there, so if you can't work them out then you can probably grab what you need from my unrelated post from which I grabbed this source code.
How to get Umbraco Image Full File Path
Hi,
Please can anyone help. I have been fiddling around far too much trying to figure this out. Any help would be awesome :)
I just want to full file page of an umbraco image Eg C:\Dropbox\Web\sycacouk\Source Code\Website\media\1078\testimage.png
I have manged to write code for a Media item like pdf but the same code just doesn't work for an image
This is the code I used for a file like PDF
I got errors if I passed an image Id rather than a file Id. I attempted to modify it slightly but no job.
Eg
I googled around and found loads of examples that were old or didn't work. the closet I got to what I want is.
but this returned a strange string (Not what I want)
Anyone got any idea how to get the full file path either from this string or any other way?
Much Appreciated
David
Hi David (great name!!!)
Try this:
You're probably missing a few namespaces there, so if you can't work them out then you can probably grab what you need from my unrelated post from which I grabbed this source code.
David
Hi Dave,
Awesome! Thanks for your help. You save me a heap of time Googling this again tomorrow.
This is exactly what I needed. Just needed to add the MapPath around but nothing major.
Thanks again. Hope I can re-pay the favor something!
Kind Regards
David
is working on a reply...