I have some strange issues with umbrac.library.GetMedia. Consider the example blow. I have a property called storeIcon which has data type Media Picker. When I store this property in a variable and output the variable the value 1254 is printed. When I pass this variable into the GetMedia method the xslt crash with error System.OverflowException: Value was either too large or too small for an Int32. When I hard code its value (as the example shows below) the image is rendered. What am I doing wrong here?
Passing variable to GetMedia causes error
Hey,
I have some strange issues with umbrac.library.GetMedia. Consider the example blow.
I have a property called storeIcon which has data type Media Picker. When I store this property in a variable and output the variable the value 1254 is printed. When I pass this variable into the GetMedia method the xslt crash with error System.OverflowException: Value was either too large or too small for an Int32. When I hard code its value (as the example shows below) the image is rendered. What am I doing wrong here?
Hey,
If you add a check like this your problem will go away.
<xsl:for-each select="current()/* [name() = $recordStoreTypeAlias]">
<xsl:variable name="storeIcon" select="number(storeIcon)" />
<xsl:value-of select="$storeIcon"/>
<xsl:if test="$storeIcon != '' ">
<xsl:variable name="thumbnail" select="umbraco.library:GetMedia($storeIcon, 0)" /> <--This row generates the error
</xsl:if>
<xsl:variable name="thumbnail" select="umbraco.library:GetMedia('1254', 0)" /> <-- This row works
<img src="{$thumbnail/umbracoFile}" />
</xsl:for-each>
Rich
It didn't work. Still the same error.
Sorry!
Should be
<xsl:if test="$storeIcon > 0>
<xsl:variable name="thumbnail" select="umbraco.library:GetMedia($storeIcon, 0)" />
</xsl:if>
Rich :)
Got it working now!
Instead of using a variable I check the storeIcon property directly in the if-statement and then use it in the GetMedia method if it is not empty.
is working on a reply...