after searching for hours on the forum and google I ended up here to ask the questions so many other people asked before. I am still not able to render images with XSLT.
I have added some images to the Media-library. First I added them to a folder, but just to make it easier I added them to the root. There is a document type called Styremedlem with several properties. The property for the image is called boardImage and is of the type MediaPicker. I have tried at least 20 different versions of XSLT from the forum to render an image, but still no success.
System.OverflowException: Value was either too large or too small for an Int32.
..
..
I have other fields in the same XSLT which renders perfectly.
Just as a test I wrote the XSLT below to see if its possible to get out the ID for the image, and this returns the ID correctly.<xsl:value-of select="boardImage"/>
thank you for following up. No, I didnt find the solution.
Yes, I will also implement this test to see if the media picker is empty. However, my problem starts before this. My problem starts at your first statement <xsl:variablename="media"select="umbraco.library:GetMedia($currentPage/imageAlias, 0)"/>
The name of my propety (which is of the type media picker) is boardImage, so the my statement is exactly like this <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/boardImage, 0)"/>
The result when I try to save the XSLT it failes and prints:
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
After a lot of struggling I found the problem and the rendering of images works fine :-)
The problem was, which I dont fully understand yet, that I had to remove the $currentPage. I am running a for-each (<xsl:for-each select="$currentPage/*) so it looks like $currentPage must not be used later on. I must look more into this.
Anyway, the problem was solved. Thank you Dennis and Alex for your help
Render image with XSLT
Hi,
Version: 4.7.1.1
after searching for hours on the forum and google I ended up here to ask the questions so many other people asked before. I am still not able to render images with XSLT.
I have added some images to the Media-library. First I added them to a folder, but just to make it easier I added them to the root. There is a document type called Styremedlem with several properties. The property for the image is called boardImage and is of the type MediaPicker. I have tried at least 20 different versions of XSLT from the forum to render an image, but still no success.
The XSLT looks like this:
<xsl:variable name="mediaId" select="number($currentPage/boardImage)" />
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
This returns in the "XSLT-editor" an exception:
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
..
..
I have other fields in the same XSLT which renders perfectly.
Just as a test I wrote the XSLT below to see if its possible to get out the ID for the image, and this returns the ID correctly.<xsl:value-of select="boardImage"/>
Thank You!
Cheers,
Eirik
Hi Eirik,
Why you need number function here ?
<xsl:variable name="mediaId" select="number($currentPage/boardImage)" />
We always use string, example:
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($currentPage/boardImage, 0)" />
Thanks,
Alex
Hi Alex,
thanks for your reply.
When I use your example I get an exception in the "XSLT-editor" when saving.
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
Thank you,
Eirik
Are you sure that you pass media ID to the method?
Thats what I tried to do here: <xsl:variable name="mediaId" select="number($currentPage/boardImage)" />
And then use the mediaid variable further on.
Your way however this should not be necessary I guess, and I could use the variable mediaNode. but also in this case I get the exception.
Eirik
please, see in add_data/umbraco.config what contains in boardImage property
I checked, and yes it contains the boardImage property.
I guess that is verified since <xsl:value-of select="boardImage"/> prints the ID of the boardImage correctly.
Eirik
Hi Erik,
Did you find a solution to your problem with the image,
When I work with images in Umbraco I always print them like Alex mentioned in a previous post, but I always do a check on the media picker to check if it is empty.
Hope this can help you further if you have not already found a solution,
/Dennis
Hi Dennis,
thank you for following up. No, I didnt find the solution.
Yes, I will also implement this test to see if the media picker is empty. However, my problem starts before this. My problem starts at your first statement <xsl:variablename="media"select="umbraco.library:GetMedia($currentPage/imageAlias, 0)"/>
The name of my propety (which is of the type media picker) is boardImage, so the my statement is exactly like this <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/boardImage, 0)"/>
The result when I try to save the XSLT it failes and prints:
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
Eirik
Hi Erik,
Okay donĀ“t know if this small change will do the trick,
I forgot the add the not equal to empty statement to the if
I hope this will do the trick for you
/Dennis
Thanks again for your reply Dennis.
After a lot of struggling I found the problem and the rendering of images works fine :-)
The problem was, which I dont fully understand yet, that I had to remove the $currentPage. I am running a for-each (<xsl:for-each select="$currentPage/*) so it looks like $currentPage must not be used later on. I must look more into this.
Anyway, the problem was solved. Thank you Dennis and Alex for your help
Cheers, Eirik
is working on a reply...