Ewatkins wrote:This applies to v4 beta 2..
Also in my template I am calling this:
<img src="<umbraco:Item field='placeImage' runat='server'></umbraco:Item>" alt="" />
placeImage is the name of the media picker. Is that correct?
Hi Evan,
I ran into something similar I think (if I am understanding you correctly). What you are getting back as part of your "placeImage" field is the ID of the media item, correct? So, your image tag probably looks something like:
Code:<img src="1025" alt="" />
To solve this, you will need to create some XSLT. I ended up using something that Douglas Robar suggested a while back that looks like this:
Code:<!-- MACRO PARAMS -->
<xsl:variable name="imgAlias" select="/macro/imgAlias"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:if test="$imgAlias != ''">
<img>
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias=$imgAlias], 'false')/data [@alias='umbracoFile']" />
</xsl:attribute>
<!--<xsl:attribute name="width">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias=$imgAlias], 'false')/data [@alias='umbracoWidth']" />
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias=$imgAlias], 'false')/data [@alias='umbracoHeight']" />
</xsl:attribute>-->
<xsl:attribute name="alt">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias=$imgAlias], 'false')/@nodeName" />
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
That should do the trick for ya. Just include this in a macro, and pass in the name of the field like so:
Code:<umbraco:Macro imgAlias="nameOfImageAlias" Alias="NameOfMacro" runat="server"></umbraco:Macro>
Hope this helps.
Best,
Nik
Level 1 Certified /
www.scandiaconsulting.com