Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • julian k 3 posts 23 karma points
    Apr 12, 2011 @ 08:32
    julian k
    0

    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('&lt;img src=&quot;', umbraco.library:GetMedia({0},false())/*/umbracoFile, '&quot; /&gt;')" xsltDisableEscaping="true" />, changing the {0} for a number,  but it displays nothing. I am using Ambraco 4.7


    J

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 12, 2011 @ 08:36
    Jan Skovgaard
    0

    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

  • Ove Andersen 435 posts 1541 karma points c-trib
    Apr 12, 2011 @ 10:00
    Ove Andersen
    0

    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.

  • julian k 3 posts 23 karma points
    Apr 12, 2011 @ 15:00
    julian k
    0

    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>

  • Ove Andersen 435 posts 1541 karma points c-trib
    Apr 12, 2011 @ 16:38
    Ove Andersen
    0

    Try to change 

    <xsl:if test="$media"> 

    to

    <xsl:if test="string($media)!=''"> 
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies