could someone tell me in NEWBIE terms what exactly am I supposed to do to return the URL... would help alot and springboard me on my XSLT endeavors... Thanks!
But to make it work, you have to place this code inside of a XSLT-file, and then place a macro containing the XSLT inside of your masterpage. You can do like this:
1. Go to the developer section in Umbraco and right-click the XSLT-folder. Here you'll choose to create a new XSLT.
2. Name the XSLT, and make sure that there's a checkmark in the "Create macro"-checkbox. Just choose a Clean XSLT-file.
3. Now you have created a new XSLT-file and a macro containing the file. In the XSLT-file you'll paste in the above code.
4. Now you'll go to the settings section of Umbraco, and insert the new macro in your masterpage.
5. You'll do this by clicking the small icon in the top called "Insert macro" - Choose the new macro you just created.
6. Save the masterpage and you should be done.
I hope the above mini guide makes sense and works for you :)
System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) 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 Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) 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)
Very New to XSLT and need to out the URL of an Image using the Media Picker
Currently the Media Picker outputs the id of the image.
From this page: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia
it states I'm suppose to use this format for version 4.5 and higher:
could someone tell me in NEWBIE terms what exactly am I supposed to do to return the URL... would help alot and springboard me on my XSLT endeavors... Thanks!
Hey Kevon,
Are you using v4.5.0 or v4.5.1? (There was a minor bug in v4.5.0 with GetMedia).
Hopefully you are using v4.5.1, if so, then you were so close!
Just needed to remove the 'Image' bit (that was the bug in v4.5.0)
Cheers, Lee.
4.5.1
I understand $media is a variable that gets it's value from the first element... so would this be correct:
<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/myIMAGE, 0)" />
<img src="{$media/umbracoFile}" alt="{$media/altText}" /> ?
Yes, it looks correct to me. Give it a go, see what happens! :-)
Well doing it this way
I get the following output:
and doing it this way:
I get the following output:
ignore the font differences. I'm using the alias of the media picker below in bold:
Hi Kevon,
Where have you placed this code? in an XSLT or (Master) Template?
You can't use .NET controls (like <umbraco:Item>) in XSLT and vice-versa, XSLT tags in Templates (i.e. <xsl:variable>)
Let me know what you are using so far, then I can suggest a way to help.
Thanks, Lee.
I inserted this directly into MasterPage. Please advise procedure.
Hi there Kevon
The XSLT that you have provided above looks right:
But to make it work, you have to place this code inside of a XSLT-file, and then place a macro containing the XSLT inside of your masterpage. You can do like this:
1. Go to the developer section in Umbraco and right-click the XSLT-folder. Here you'll choose to create a new XSLT.
2. Name the XSLT, and make sure that there's a checkmark in the "Create macro"-checkbox. Just choose a Clean XSLT-file.
3. Now you have created a new XSLT-file and a macro containing the file. In the XSLT-file you'll paste in the above code.
4. Now you'll go to the settings section of Umbraco, and insert the new macro in your masterpage.
5. You'll do this by clicking the small icon in the top called "Insert macro" - Choose the new macro you just created.
6. Save the masterpage and you should be done.
I hope the above mini guide makes sense and works for you :)
/Kim A
Problem: I inserted the bold XSLT below in the Clean XSLT Template:
Upon save I got the following error:
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
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 Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
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)
Try changing the two lines to this:
This will make sure that there's actually choosen an image in the picker. Otherwise no image will be rendered in the HTML.
/Kim A
Like Ambien, it worked like a dream.
Thanks.
is working on a reply...