I am trying to pull some pictures from child elements using xslt, which I am not familiar of :( .
basically documents have property "pictureUrl".
To list all the links to subpages I use built in template 'list subpages from current page' but alogside I would also like to show the pictures too. I can create pure list by using: <xsl:value-of select="pictureUrl"/> syntax but when I try to put it into <img src="#" /> I get some errors.
If you've created the pictureUrl property as a Media Picker, you need to use an extension method from the umbraco.library namespace, otherwise you shoud be able to just use curly-braces to get it in - try these:
First - assume an upload field (or a URL textbox):
If that doesn't work, try this one - assumes a Media Picker was used:
<xsl:template match="/">
<!-- GetMedia() will complain if no image was picked, so need to check -->
<xsl:if test="normalize-space($currentPage/pictureUrl)">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($currentPage/pictureUrl, false()" />
<img src="{$mediaNode/umbracoFile}" width="{umbracoWidth}" height="{umbracoHeight}" alt="{@nodeName}" />
</xsl:if>
</xsl:template>
creating img tab from xslt
hi guys,
I am trying to pull some pictures from child elements using xslt, which I am not familiar of :( .
basically documents have property "pictureUrl".
To list all the links to subpages I use built in template 'list subpages from current page' but alogside I would also like to show the pictures too. I can create pure list by using: <xsl:value-of select="pictureUrl"/> syntax but when I try to put it into <img src="#" /> I get some errors.
Can you help?
Thanks in advance.
Hi pawel,
If you've created the pictureUrl property as a Media Picker, you need to use an extension method from the umbraco.library namespace, otherwise you shoud be able to just use curly-braces to get it in - try these:
First - assume an upload field (or a URL textbox):
If that doesn't work, try this one - assumes a Media Picker was used:
/Chriztian
thanks a lot Chriztian,
I use simple Textstring as a type and for some reason these solutions don't work....
maybe it has something to do with umbraco version, it is an older one 4.5.2?
regards,
I think I have it, I should simply have used
<img src="{pictureUrl}" />
:)
Thanks again!
is working on a reply...