Just discovers that setting the umbraco library cache duration to 0 fixes the problem - so something is wrong with the cache? Or should I be using another method to get media url in codebehind?
I was looking at the source, and it seems that there might be a bug.
What does it return if you do this:
public string GetMediaFile(string nodeId)
{
string url = String.Empty;
int mediaId = 0;
if (Int32.TryParse(nodeId, out mediaId))
{
XPathNodeIterator xn = umbraco.library.GetMedia(mediaId, false);
//This movenext fails on the second request
if (xn.MoveNext())
{
return xn.Current.OuterXml;
}
}
return url;
}
I'm guessing you might get something like "<error>No media is maching '{0}'</error>"
We have had the same issue happen to use for about 6-7 months now and could not figure out the issue, but it was happening with our XSLT files. Thanks for the find, but that is kind of a horky fix. Caching would be nice. Is there a fix? We are using Umbraco 4.7.1
umbraco.library.GetMedia only finding node on first try after Republish Entire Site
Hi,
Strange problem with a 4.5.2 site.
I'm using umbraco.library.GetMedia in some backend code. Here's the code:
The thing is it only returns the media item on the first request after a republish.
Very strange. Would anyone have any idea why this might be happening?
Just discovers that setting the umbraco library cache duration to 0 fixes the problem - so something is wrong with the cache? Or should I be using another method to get media url in codebehind?
I was looking at the source, and it seems that there might be a bug.
What does it return if you do this:
I'm guessing you might get something like "<error>No media is maching '{0}'</error>"
We have had the same issue happen to use for about 6-7 months now and could not figure out the issue, but it was happening with our XSLT files. Thanks for the find, but that is kind of a horky fix. Caching would be nice. Is there a fix? We are using Umbraco 4.7.1
is working on a reply...