Displaying an image from Media Picker in a web page
I'm new to Umbraco and am trying to do something very simple.
1. I uploaded some images into Umbraco
2. On the document type created a Media Picker
3. created a new page and pointed the Media Picker at the uploaded image
4. In the template I added the reference to the Media Picker
All i get is the number of the image displayed in the web page. I have looked at several articles and created a few macros but none seem to work.
All i want to do is display the image from the media picker on the web page. It must be simple but i just cannot figure it out. Any easy step by step assistance would be appreciate.
I have tried <umbraco:Item runat="server" field="imagecontent" xslt="concat('<img src="', umbraco.library:GetMedia({0},false())/*/umbracoFile, '" />')" xsltDisableEscaping="true" />, changing the {0} for a number, but it displays nothing. I am using Ambraco 4.7
You need to create an XSLT macro to fetch the image since using umbraco:Item will only return the id of the image node in the media folder.
Try having a look in this wiki reference about GetMedia. This shows how you can create the XSLT in a XSLT file, which can be inserted into your template afterwards.
so i take the following, create a new XSLT and add this in where it says <!-- start writing XSLT -->. If so when i do this i get an error! System.OverflowException: Value was either too large or too small for an Int32.
Displaying an image from Media Picker in a web page
I'm new to Umbraco and am trying to do something very simple.
1. I uploaded some images into Umbraco
2. On the document type created a Media Picker
3. created a new page and pointed the Media Picker at the uploaded image
4. In the template I added the reference to the Media Picker
All i get is the number of the image displayed in the web page. I have looked at several articles and created a few macros but none seem to work.
All i want to do is display the image from the media picker on the web page. It must be simple but i just cannot figure it out. Any easy step by step assistance would be appreciate.
I have tried <umbraco:Item runat="server" field="imagecontent" xslt="concat('<img src="', umbraco.library:GetMedia({0},false())/*/umbracoFile, '" />')" xsltDisableEscaping="true" />, changing the {0} for a number, but it displays nothing. I am using Ambraco 4.7
J
Hi Julian
You need to create an XSLT macro to fetch the image since using umbraco:Item will only return the id of the image node in the media folder.
Try having a look in this wiki reference about GetMedia. This shows how you can create the XSLT in a XSLT file, which can be inserted into your template afterwards.
http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia
Please note that you should use the example based on the version 4.5 syntax.
Hope this helps.
/Jan
Look at the last code block on this page:
http://our.umbraco.org/wiki/reference/templates/umbracoitem-element/inline-xslt
It should do what you want.
Sorry
so i take the following, create a new XSLT and add this in where it says <!-- start writing XSLT -->. If so when i do this i get an error! System.OverflowException: Value was either too large or too small for an Int32.
<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/imageAlias, 0)" />
<xsl:if test="$media">
<img src="{$media/umbracoFile}" alt="{$media/altText}" />
</xsl:if>
Try to change
<xsl:if test="$media">
to
<xsl:if test="string($media)!=''">
is working on a reply...