Copied to clipboard

Flag this post as spam?

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


  • Louis 37 posts 59 karma points
    Dec 30, 2011 @ 12:08
    Louis
    0

    Displaying an image in the XSLT

    I'm pretty new to umbraco but found the system pretty easy to use and have done alot in a short space of time. One difficulty I have come accross is displaying an image.

    In the document type I have added an "upload" where an image is selected. In my XSLT I loop through the pages, this loop displays the other fields such as description or title. I am trying to display the image here.

    Here is my XSLT for displaying my image, this displays nothing. The field "promothumbImage" is defined in the document type, as I said everything else is working fine.

    <xsl:value-of select="promothumbImage"/>

    Does anyone have any ideas as to where I am going wrong?

    EDIT:

    promothumbimage is defined in the document of type "upload"

    <!-- The fun starts here -->
    <div class="promoitems">

     
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and
     string(umbracoNaviHide) != '1']"
    >
     
    <div class="promoitem">

    <a href="{umbraco.library:NiceUrl(@id)}">
     
    <xsl:value-of select="@nodeName"/>
    </a>

    <div class="promosmalldesc">
     
    <xsl:value-of select="promoSmallDesc"/>
    </div>

    IMAGE HERE
    <xsl:copy-of select="promothumbImage/*"/>


     
    </div>

     
    </xsl:for-each>

  • Stephen 204 posts 246 karma points
    Dec 30, 2011 @ 13:00
    Stephen
    0

    Hi Louis,

    You still need the img tag...here is a sample from one of my site which uses imagegen (fantastic package)

    <img src="/ImageGen.ashx?image={current()/photo}&width=150&height=100&constrain=true" alt="{@nodeName}" />

    you need the alias of the image, in my case "photo". In your case i think it will be "promothumbImage" (is that the alias for it?) so something like the following will work.

    <img src="{promothumbImage}" alt="{@nodeName}" />

    Hope this helps.

    S


  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 30, 2011 @ 13:01
    Jan Skovgaard
    1

    Hi Louis and welcome to our :)

    When you're using the upload property then you should be able to fetch the image by just writing out the value, which should hold the path.

    Like this: <xsl:value-of select="promothumbImage" />. In order to write out an <img> tag to actually display the image you would need to write it like this:

    <img src="{promothumImage}" />, which should render your image.

    If you at some point need to render a image selected with a media picker you will need to use the GetMedia extension, to fetch the image. You can read more about that here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia (Look at the example for Umbraco 4.5 since that is the XML schema that is being used with 4.5+ Umbraco installations).

    Hope this helps.

    /Jan

  • Louis 37 posts 59 karma points
    Dec 30, 2011 @ 13:16
    Louis
    0

    YES YES YES YES YES!!!!!! thanks Jan!!!!! Worked great!!!!!! I've been banging my head for a long time on this!!!! 

    Hope you have a happy new year!

    Louis

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 30, 2011 @ 13:21
    Jan Skovgaard
    0

    Hi Louis

    I'm very happy to hear that. You're very welcome. Please don't hesitate to ask about anything Umbraco related in here since it can probably save you a lot of frustration - you should also be aware that you can find many xslt extensions out of the box that can ease some tasks for you - simply just have a look at the wiki link I posted above.

    And maybe at some point you can benefit from checking out the uComponents package, which is also filled with extension etc. to make our lifes even more easy :)

    ...And a happy new year to you!

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft