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
HiIm trying to inherit a image value and can get the id value working fine using
<xsl:value-of select="$currentPage/ancestor-or-self::node [string(data[@alias='headerImage'])!=''] [1] /data[@alias='headerImage']"/>
which gives me the id. How do i parse this using /data[@alias='umbracoFile so I can see the image? Can't seem to get the syntax working
Thanks / Niklas
Here's a good approach from Lee Kelleher's blog, which is a "super safe" way to do it i.e. handles eventualities where the id isn't present etc:
<xsl:template match="/"> <xsl:variable name="mediaId" select="number($currentPage/data[@alias='mediaId'])" /> <xsl:if test="$mediaId > 0"> <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" /> <xsl:if test="count($mediaNode/data) > 0"> <xsl:if test="string($mediaNode/data[@alias='umbracoFile']) != ''"> <img src="{$mediaNode/data[@alias='umbracoFile']}" alt="[image]"> <xsl:if test="string($mediaNode/data[@alias='umbracoHeight']) != ''"> <xsl:attribute name="height"> <xsl:value-of select="$mediaNode/data[@alias='umbracoHeight']" /> </xsl:attribute> </xsl:if> <xsl:if test="string($mediaNode/data[@alias='umbracoWidth']) != ''"> <xsl:attribute name="width"> <xsl:value-of select="$mediaNode/data[@alias='umbracoWidth']" /> </xsl:attribute> </xsl:if> </img> </xsl:if> </xsl:if> </xsl:if></xsl:template>
It looks a lot more intimidating than it really is, as it does check for loads of things rather than just 'get the media item from the id' but you should be able to easily trim it down if you do consider it overkill at all.
Hope this helps...
Thanks for the tip. Using
<xsl:variable name="mediaId" select="number($currentPage/ancestor-or-self::node [string(data[@alias='headerImage'])!=''] [1] /data[@alias='headerImage'])"/>
works like a charm :)
/ Niklas
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get recursive image
Hi
Im trying to inherit a image value and can get the id value working fine using
<xsl:value-of select="$currentPage/ancestor-or-self::node [string(data[@alias='headerImage'])!=''] [1] /data[@alias='headerImage']"/>
which gives me the id. How do i parse this using /data[@alias='umbracoFile so I can see the image? Can't seem to get the syntax working
Thanks / Niklas
Here's a good approach from Lee Kelleher's blog, which is a "super safe" way to do it i.e. handles eventualities where the id isn't present etc:
It looks a lot more intimidating than it really is, as it does check for loads of things rather than just 'get the media item from the id' but you should be able to easily trim it down if you do consider it overkill at all.
Hope this helps...
Thanks for the tip. Using
<xsl:variable name="mediaId" select="number($currentPage/ancestor-or-self::node [string(data[@alias='headerImage'])!=''] [1] /data[@alias='headerImage'])"/>
works like a charm :)
/ Niklas
is working on a reply...