I have to show my complete ignorance here. On my homepage template I have added a media picker. Via this media picker I have selected an image from the media section. On the homepage, no image is displayed - only an ID relating to that image. Why does the image not display?
Is there an easier way for the user to select an image which then appears on the page?
I think the easiest way is to add a Richtext editor property to the document type. In the Content section edit that property by adding an image with the Insert/edit image button and in the template show the property:
Thanks very much for the suggestion. It certainly would be the easiest way. The only thing I would say is that my client will be quite particular about how the backend looks. Having three richtext editors to edit just three images will make the edit screen a bit harder to deal with.
I understand that XSLT can be used to display the image selected by the media picker but that solution seems so bloated. Do you know if anyone has developed a plug-in for selecting and displaying images on the page? Or an XSLT file that grabs the ID and shows the image?
where articleImage is the alias of the media property.You just need to put this in an xslt file, create a macro that uses this xslt and call the macro from the Home template.
I think your response is exactly what I'm looking for, only I don't know how to enact it.
"where articleImage is the alias of the media property." - I don't get this part I'm afriad, which is probably why the XSLT will be showing the following error;
Error occured
System.Xml.Xsl.XslLoadException:
The variable or parameter 'articleImage' is either not defined or it is
out of scope. An error occurred at
C:\HostingSpaces\elmahdi.co.uk13\click.tnt.com\wwwroot\xslt\634157564506310000_temp.xslt(19,9).
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String
fileName, String oldName, String fileContents, Boolean ignoreDebugging)
You said: "On my homepage template I have added a media picker." What I understood is that you added a media picker property to the document type associated to the Home page.
If it's so, then instead of articleImage you have to write the alias of your property.
If what I understood is wrong, can you explain exactly what you did?
System.Xml.Xsl.XslLoadException:
The variable or parameter 'fastBox1Image' is either not defined or it
is out of scope. An error occurred at
C:\HostingSpaces\elmahdi.co.uk13\click.tnt.com\wwwroot\xslt\634157601103640000_temp.xslt(19,9).
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String
fileName, String oldName, String fileContents, Boolean ignoreDebugging)
I cannot change it to false as yet as it is still not saving.
I am really sorry, it was my fault. The $artcileImage was actually a parameter in my code, but I didn't realise it before pasting it. So here's the code that should work:
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, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
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, Boolean closeWriter)
at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable
contextDocument, XmlResolver dataSources, XsltArgumentList argumentList,
XmlWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable
contextDocument, XmlResolver dataSources, XsltArgumentList argumentList,
TextWriter results)
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)
But when I surround the value-of with an if it saves ok!
I know I'm pushing my luck here so only answer if it's very easy. How can I accomodate fastBox2Image (and so on)? I'm sure I'll get there if I persevere!
You just do it all again. Add fastBox2Image property to the document type, give it a value in the Content section and add the same xslt code for fastBox2Image alias.
When I started working with umbraco, the wiki and the examples I found helped me quite much. It took some time though.
Completely stupid media picker question
Hi all,
I have to show my complete ignorance here. On my homepage template I have added a media picker. Via this media picker I have selected an image from the media section. On the homepage, no image is displayed - only an ID relating to that image. Why does the image not display?
Is there an easier way for the user to select an image which then appears on the page?
My Umbraco version is umbraco v 4.0.3
Thanks very much for any help received.
Hi David,
I think the easiest way is to add a Richtext editor property to the document type. In the Content section edit that property by adding an image with the Insert/edit image button and in the template show the property:
Let me know if you need more help.
Mirela.
Hi Mirela,
Thanks very much for the suggestion. It certainly would be the easiest way. The only thing I would say is that my client will be quite particular about how the backend looks. Having three richtext editors to edit just three images will make the edit screen a bit harder to deal with.
I understand that XSLT can be used to display the image selected by the media picker but that solution seems so bloated. Do you know if anyone has developed a plug-in for selecting and displaying images on the page? Or an XSLT file that grabs the ID and shows the image?
Again, thanks a lot for the help,
David.
Hey David, I don't know a plug-in or a xslt file that does that, but I know the xslt call:
where articleImage is the alias of the media property.You just need to put this in an xslt file, create a macro that uses this xslt and call the macro from the Home template.
Hope it helps,
Mirela.
Hi Mirela,
I think your response is exactly what I'm looking for, only I don't know how to enact it.
"where articleImage is the alias of the media property." - I don't get this part I'm afriad, which is probably why the XSLT will be showing the following error;
Error occured
System.Xml.Xsl.XslLoadException: The variable or parameter 'articleImage' is either not defined or it is out of scope. An error occurred at C:\HostingSpaces\elmahdi.co.uk13\click.tnt.com\wwwroot\xslt\634157564506310000_temp.xslt(19,9).
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
Thanks for your help!
David.
You said: "On my homepage template I have added a media picker." What I understood is that you added a media picker property to the document type associated to the Home page.
If it's so, then instead of articleImage you have to write the alias of your property.
If what I understood is wrong, can you explain exactly what you did?
Mirela.
Hi Mirela,
You were right, I added a media picker on the homepage document type with the alias fastBox1Image and added it to the template using this code;
<umbraco:Item field="fastBox1Image" runat="server"></umbraco:Item>
I then attempted to make the XSLT file using this code before receiving the error;
<img alt="">
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia($fastBox1Image, 'true')/data [@alias = 'umbracoFile']"/>
</xsl:attribute>
</img>
I am no doubt making an obvious mistake somewhere.
Thanks again,
David.
What is the error this time?
And another thing, instead of GetMedia($fastBox1Image, 'true'), can you trey GetMedia($fastBox1Image, 'false')?
True is for items inside a folder.
Hi Mirela,
here is the error
Error occured
System.Xml.Xsl.XslLoadException: The variable or parameter 'fastBox1Image' is either not defined or it is out of scope. An error occurred at C:\HostingSpaces\elmahdi.co.uk13\click.tnt.com\wwwroot\xslt\634157601103640000_temp.xslt(19,9).
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
I cannot change it to false as yet as it is still not saving.
You have the patience of a saint!
I am really sorry, it was my fault. The $artcileImage was actually a parameter in my code, but I didn't realise it before pasting it. So here's the code that should work:
or
I don't have time now to test the second one, but it should work.
Sorry again,
Mirela
Thanks again for the reply. I'll give it a try in the morning when I get into work. Don't apologise for the mistake, your a great help!
Hi Mirela,
I now receive this 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, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
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, Boolean closeWriter)
at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results)
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)
But when I surround the value-of with an if it saves ok!
<xsl:variable name="fastBox1Image" select="data [@alias = 'fastBox1Image']"></xsl:variable>
<img alt="">
<xsl:attribute name="src">
<xsl:if test="CONDITION">
<xsl:value-of select="umbraco.library:GetMedia($fastBox1Image, 'false')/data [@alias = 'umbracoFile']"/>
</xsl:if>
</xsl:attribute>
</img>
Why would the xsl:if test make a difference?
I've tested now the code I've sent you and the correct version is:
<xsl:variable name="fastBox1Image" select="$currentPage/data [@alias = 'fastBox1Image']"></xsl:variable>
<img alt="">
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia($fastBox1Image, 'false')/data [@alias = 'umbracoFile']"/>
</xsl:attribute>
</img>
The bolded part is the correct select for that variable.
The exception was becauuse umbraco.library.GetMedia was expecting an int as the first parameter and the value of $fastBox1Image was probably null.
You're an absolute hero. This is awesome! It's everything I've ever dreamed of and more! You've made a young designer very happy.
Thanks for persevering with my lack of knowledge.
Now Umbraco just need to make this a standard feature and everything will be sorted.
Thanks again!
I know I'm pushing my luck here so only answer if it's very easy. How can I accomodate fastBox2Image (and so on)? I'm sure I'll get there if I persevere!
Thanks one last time,
David.
You just do it all again. Add fastBox2Image property to the document type, give it a value in the Content section and add the same xslt code for fastBox2Image alias.
When I started working with umbraco, the wiki and the examples I found helped me quite much. It took some time though.
Good luck,
Mirela.
That's great. I will definitely invest some time in the wiki. Thanks for your help - you saved the day!
David.
is working on a reply...