Copied to clipboard

Flag this post as spam?

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


  • Candice 14 posts 34 karma points
    Sep 14, 2010 @ 14:34
    Candice
    0

    Showing an image in a template

    Hi,

     I have been trying without success to show an image from my master template. I watched the xslt videos and still I cannot get it to work. I have a MasterPage which I want to put my TopBanner.gif in, so that it shows on every page in the site (they will all use the MasterPage). I went to the Media section and uploaded my image file, named TopBanner.gif.  In my MasterPage template, I put this code:

    <umbraco:Item runat="server" field="mediaItem"
    xslt="concat('&lt;img src=&quot;', umbraco.library:GetMedia({0},'true')/ data[@alias='TopBanner'], '&quot; /&gt;')"
    XsltDisableEscaping="true" />

    Nothing displays.I also tried it with 'TopBanner.gif', and tried other code snippets similar to the above but nothing will work.

    Can anyone figure out what I'm doing wrong? Also, although I can find videos that explain the usage of xslt, I cannot find one that specifically shows how to display an image - is there one? 

    I'm disappointed that so many other things in Umbraco are great and easy to do, but something as simple and common as displaying an image is so difficult. Or maybe I'm just missing something!

    thanks,

    Candice

     

     

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 14, 2010 @ 15:07
    Dirk De Grave
    0

    Candice,

    what umbraco version are you using? If using old syntax (pre v4.5), then snippet should be

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

    If using the new xml schema, use

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

    or

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

    (last 2 snippets depend on the v4.5.x version since there used to be a bug - from what I read in other posts)

    Hope this helps.

    Regards,

    /Dirk


  • Candice 14 posts 34 karma points
    Sep 15, 2010 @ 03:06
    Candice
    0

    Hi Dirk,

     I am using the latest version of Umbraco. I tried all 3 of your snippets but none worked! I'm wondering if I've done something wrong when I uploaded the images. I went to Media, right-clicked, clicked 'create', I chose 'image' and gave it a name. Then I clicked save. 

    I think at this point I am going to see if there are any sample websites I can install and inspect. I still can't believe it's this difficult. Adding an image to a webpage has got to be one of the most common tasks a web designer does.

    thank you.

    Candice

     

     

     

     

  • Candice 14 posts 34 karma points
    Sep 17, 2010 @ 19:32
    Candice
    0

    I think I know what might be wrong...people are giving me code to display an image loaded with the mediapicker...but I don't think I am using the mediapicker (not sure what that is at this point). All I did was go to the Media section and upload my image file, named TopBanner.gif.  Is there different code to place the image on a template if it is not being done with the mediapicker?

    This is not an image that the user will select. It's an image that's going to appear on all of their pages, so I want to add it to my MasterPage. It won't be changing.

    thanks.

  • Phil 12 posts 32 karma points
    Sep 24, 2010 @ 17:40
    Phil
    0

    When I did this, I created a 'MyImages' folder in the site root, and manually put the image there, then just used the normal image tag 

    <img src="/MyImages/Banner.gif" alt="MyNanner" />

    Hope this helps

  • Candice 14 posts 34 karma points
    Sep 24, 2010 @ 21:42
    Candice
    0

    Phil,

     Thanks for the info - I eventually figured out that this was what I needed to do. Too bad I spent such a long time figuring it out! Hopefully this post will help someone else!

    Candice

Please Sign in or register to post replies

Write your reply to:

Draft