which should return the file path of the media item (which is a image)
however what im getting back is the is something like:
\media\1033\testimage.jpg102476834567jpg
i have search a couple of topics now with a similar issue and made sure the "data [@alias='umbracoFile']" is correct, is there something i might be missing, overlooking, maybe a blonde moment ??
Which version of Umbraco are you using? If it's v4.5, then do you know if you are using the legacy XML schema? It could be that you are using the new XML schema, so the XPath expression isn't returning the correct value.
To be honest, if you are doing this in .NET code, I wouldn't recommend using the GetMedia method (as XPathNodeIterators are waaaaaay horrid to work with in C#).
Try something like this:
int nodeId = 1234; // get this from wherever!
var media = new umbraco.cms.businesslogic.media.Media(nodeId);
var file = media.getProperty("umbracoFile");
string url = file.Value;
I'd add a couple of checks to make sure that the "media" and "file" variables aren't NULL, etc.
Retieve file path of media image
Hi,
i have the following code inside a .net usercontrol:
XPathNodeIterator xn = umbraco.library.GetMedia(NodeID.As<int>(0), false);
xn.MoveNext();
string url = "";
XPathNodeIterator xn2 = xn.Current.Select("data [@alias = 'umbracoFile']");
xn2.MoveNext();
url = xn2.Current.Value;
which should return the file path of the media item (which is a image)
Hey Cookie Monster,
Which version of Umbraco are you using? If it's v4.5, then do you know if you are using the legacy XML schema? It could be that you are using the new XML schema, so the XPath expression isn't returning the correct value.
To be honest, if you are doing this in .NET code, I wouldn't recommend using the GetMedia method (as XPathNodeIterators are waaaaaay horrid to work with in C#).
Try something like this:
I'd add a couple of checks to make sure that the "media" and "file" variables aren't NULL, etc.
Cheers, Lee.
Try something like this:
url = HttpContext.Current.Server.MapPath(xn2.Current.Value);
is working on a reply...