Copied to clipboard

Flag this post as spam?

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


  • Geoff Stokes 19 posts 38 karma points
    Aug 18, 2011 @ 04:20
    Geoff Stokes
    0

    Inserting an Image via a MediaPicker in a template

    Hi all,

    I've Googled and Googled and am yet to come up with an answer that works.

    What is the correct format for using a MediaPicker to display an image?

    I have tried this code (Among other potential solutions):

    <umbraco:Item field="eventImage" xslt="concat('&lt;img align=&quot;right&quot; class=&quot;image&quot src=&quot;',umbraco.library:GetMedia({0}, true())/umbracoFile, '&quot; /&gt;')" xsltDisableEscaping="true" runat="server">

    (My field name is "eventImage") and none of them work. What is the correct way to do this?

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 18, 2011 @ 04:48
    Fuji Kusaka
    0

    Hi Goeff,

     

    Are you listing a list of Images from the media section or just picking a sinlge image?..what you can try is create an XSLT file under the developer section and add it to your template. 

    Your XSLT should look like this

     <xsl:for-each select="$currentPage">  
      
        <xsl:element name="img">
          <xsl:attribute name="src">
           <xsl:value-of select="umbraco.library:GetMedia(eventImage, 'true')/umbracoFile" />
          </xsl:attribute
        </xsl:element>  
      
    </xsl:for-each>

    //fuji

  • Geoff Stokes 19 posts 38 karma points
    Aug 18, 2011 @ 05:04
    Geoff Stokes
    0

    I am selecting a single image.

    Is there really no way to do this without creating a Macro?

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 18, 2011 @ 05:28
    Fuji Kusaka
    0

    Hi Geoff you could make use of inline XSLT as you mentioned in your previous post

    <umbraco:Item runat="server" field="eventImagexslt="concat('&lt;img src=&quot;',umbraco.library:GetMedia({0}, true())/umbracoFile, '&quot; /&gt;')" xsltDisableEscaping="true"/>

    What version of umbraco are you using? The above code is for the new schema

    If you are using the old schema pre v4.5 try this instead

     

    <umbraco:Itemrunat="server"field="eventImage"xslt="concat('&lt;img src=&quot;',umbraco.library:GetMedia({0}, true())/data[@alias='umbracoFile'], '&quot; /&gt;')"xsltDisableEscaping="true"/>

     

  • Sufyan 6 posts 26 karma points
    Aug 18, 2011 @ 06:46
  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 18, 2011 @ 06:53
    Fuji Kusaka
    0

    Hi Sufyan,

    This thread is intended to help Geoff to solve his issue.

     

  • 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