The mediaLinkId variable is set correctly but the problem comes when I try and use the variable with the GetMedia call, it throws a parsing error. Should this not work?
Ah, I'm an idiot, that's the explanation! This code was in a loop and some of the elements will not have a media link id set, hence it was breaking! D'oh!
umbraco.Library:GetMedia() Problem
Can someone tell me why this doesn't work:
<xsl:variable name="mediaLinkId" select="data [@alias = 'media']"/>
<xsl:variable name="mediaUrl" select="umbraco.library:GetMedia($mediaLinkId, 1)/data" />
The mediaLinkId variable is set correctly but the problem comes when I try and use the variable with the GetMedia call, it throws a parsing error. Should this not work?
Any help would be appreciated!
Cheers,
Robert
Try wrapping a check around it
Dan
Yep, that seems to have worked, great thanks!
What's the explanation for the solution?
Robert
Ah, I'm an idiot, that's the explanation! This code was in a loop and some of the elements will not have a media link id set, hence it was breaking! D'oh!
Cheers for your quick reply!
Haha....I had this exact same problem.... and couldn't figure it out.
Shows you should always check a value of a field in code before you use it.
This drove me nuts!
is working on a reply...