"Value was either too large or too small for an Int32" with GetMedia
I am trying to get images to display with XSLT. The video tutorial must be pre-4.5.1 because it is using the old syntax $currentPage/data [@alias = 'property'], etc. I am getting this error:
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 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)
Here is the code I am attemping to use. "facultyPhoto" is the page field of the media picker. The ID number of my photo shows up on the page, but I can't get the actual picture to show.
You should be able to fix this by adding an if statement around the GetMedia call, shown below. When you save an XSLT file Umbraco attempts to validate it through the XSLT parser, and some calls (like GetMedia, NiceUrl) will fail if they are not passed a value. You can always test this by clicking the Ignore Error checkbox and saving it, then checking the front end of the website and seeing if it works.
As far as I know the URL of an image property is saved as a sub property of the image property itself along with widths and heights etc... for example:
$currentPage/facultyPhoto/umbracoFile
I might be wrong but it would be worth a go trying it out :)
Also if I am right that the URL itself is saved within the facultyPhoto property, try outputting the facultyPhoto property to a textarea, like so:
"Value was either too large or too small for an Int32" with GetMedia
I am trying to get images to display with XSLT. The video tutorial must be pre-4.5.1 because it is using the old syntax $currentPage/data [@alias = 'property'], etc. I am getting this error:
Here is the code I am attemping to use. "facultyPhoto" is the page field of the media picker. The ID number of my photo shows up on the page, but I can't get the actual picture to show.
Something must be wrong in my understanding of the syntax. (I am using syntax found here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia)
Hi Luke,
You should be able to fix this by adding an if statement around the GetMedia call, shown below. When you save an XSLT file Umbraco attempts to validate it through the XSLT parser, and some calls (like GetMedia, NiceUrl) will fail if they are not passed a value. You can always test this by clicking the Ignore Error checkbox and saving it, then checking the front end of the website and seeing if it works.
Hope this helps,
Tom
As far as I know the URL of an image property is saved as a sub property of the image property itself along with widths and heights etc... for example:
$currentPage/facultyPhoto/umbracoFile
I might be wrong but it would be worth a go trying it out :)
Also if I am right that the URL itself is saved within the facultyPhoto property, try outputting the facultyPhoto property to a textarea, like so:
<textarea>
<xsl:value-of select="$currentPage/facultyPhoto" />
</textarea>
I wanted to give something back to the forums as I have had so much help, sorry if all the above information is wrong, I am still a baby umbracoer :P
Max.
Thank-you Max and Tom! Your input got me going in the right direction. I found a blog that laid it out nicely:
From: http://blog.leekelleher.com/2010/08/11/how-to-use-umbraco-library-getmedia-in-xslt-for-umbraco-v4-5/#comment-686
No problem, glad I could help and you figured it out.
Max
is working on a reply...