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
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!
Try wrapping a check around it
<xsl:if test="string($mediaLinkId) != ''"><xsl:variable name="mediaUrl" select="umbraco.library:GetMedia($mediaLinkId, 1)/data" /></xsl:if>
Yep, that seems to have worked, great thanks!
What's the explanation for the solution?
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...
Write your reply to:
Image will be uploaded when post is submitted