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
Hi Guys,
I'm wanting to get an image through the umbraco "media picker".
I know how to bring an image through for a "for-each loop" - here is the code I use:
<xsl:for-each select="$currentPage/NODENAMEHERE"> <li> <xsl:if test="genericImageProperty > 0"> <xsl:variable name="img" select="umbraco.library:GetMedia(genericImageProperty, 0)" /> <xsl:variable name="imgPath" select="concat(substring-before($img/umbracoFile,'.'), '.jpg')" /> <img class="person-image" src="/ImageGen.ashx?image={$imgPath}&width=150&" alt="{@nodeName}" /> </xsl:if> </li> </xsl:for-each>
However, now I am wanting to get an image the same way but WITHOUT using a for-each loop.
I am using Umbraco 4.7.2
All suggestions welcome!
Jordy
However now I am wanting to get an image WITHOUT using a for-each loop
Hi Jordy,
If you know the ID of the media, maybe from a media picker etc, you can use the GetMedia XSLT extension. Here's an example from Lee Kelleher's blog post, How to use umbraco.library:GetMedia in XSLT for Umbraco v4.5
<xsl:variable name="mediaId" select="number($currentPage/mediaId)" /> <xsl:if test="$mediaId > 0"> <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" /> <xsl:if test="$mediaNode/umbracoFile"> <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" /> </xsl:if> </xsl:if>
This is assuming you have a media picker property on your current page with the alias mediaId
Hope this helps,
Tom
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get Image through media picker XSLT
Hi Guys,
I'm wanting to get an image through the umbraco "media picker".
I know how to bring an image through for a "for-each loop" - here is the code I use:
However, now I am wanting to get an image the same way but WITHOUT using a for-each loop.
I am using Umbraco 4.7.2
All suggestions welcome!
Jordy
However now I am wanting to get an image WITHOUT using a for-each loop
Hi Jordy,
If you know the ID of the media, maybe from a media picker etc, you can use the GetMedia XSLT extension. Here's an example from Lee Kelleher's blog post, How to use umbraco.library:GetMedia in XSLT for Umbraco v4.5
This is assuming you have a media picker property on your current page with the alias mediaId
Hope this helps,
Tom
is working on a reply...