Copied to clipboard

Flag this post as spam?

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


  • Keith Jackson 183 posts 552 karma points
    Jun 01, 2011 @ 11:33
    Keith Jackson
    0

    How do I show an Image?

    I know this is a newbie question, but how can I show an image, added with the upload picker in the content editor screen on the final page?

    The umbraco:item tag just shows the URL text.

    I've tried creating an XSLT macro to do this, but I can't seem to figure out how to pass a variable to the XSLT macro for the URL path. I know I can specify fields in the Macro directly. Ideally I would prefer a Razor solution to an XSLT solution if possible.

  • Richard Boelen 61 posts 153 karma points
    Jun 01, 2011 @ 12:36
    Richard Boelen
    2

    Hi,

    Lets say you have a upload picker (Media Picker) property on your DocumentType with alias photo. You can get the image url in your page with the following razor syntax:

    <umbraco:Macro runat="server" language="cshtml">
        <img src="@Model.MediaById(Model.photo).umbracoFile" alt=""/>
    </umbraco:Macro>

    Cheers, Richard

  • Keith Jackson 183 posts 552 karma points
    Jun 01, 2011 @ 19:54
    Keith Jackson
    0

    That worked like a dream - Thanks Richard!

  • Dominic Dore 18 posts 38 karma points
    Jun 01, 2011 @ 20:15
    Dominic Dore
    0

    What should I do if I am trying to render an image through a .NET usercontrol?

  • Keith Jackson 183 posts 552 karma points
    Jun 01, 2011 @ 21:45
    Keith Jackson
    0

    I'm guessing right now, but I think that the Image element (.photo in the example above) would hang off either Node.CurrentPage or Document.CurrentPage (or it may be Document.Current - not quite sure).

    Probably better off creating your question as a new topic though so it's easier for people searching to find the right solution - You'll probably end up with a better answer too! :o)

  • Dominic Dore 18 posts 38 karma points
    Jun 01, 2011 @ 23:11
    Dominic Dore
    0

    Thanks! I'd "High five!" you, but I don't have enough karma points yet. Lol

  • Johan Roug 97 posts 153 karma points
    Jun 27, 2011 @ 16:33
    Johan Roug
    0

    Or like this

    Upload picker
    <img src="@Model.photo" />

    From media gallery
    <img src="@Model.Media("photo", "umbracoFile")" alt="@Model.Name"/>

  • Tom 713 posts 954 karma points
    Jul 19, 2011 @ 02:38
    Tom
    0

    What properties are on Dynamic Media? I was looking to access the image width and height.. if it is an image! how would i check if it is an image?

    Cheers

    Tom

  • David Johnson 12 posts 32 karma points
    Aug 12, 2011 @ 13:01
    David Johnson
    0

    Thanks very much, this helped me a lot!

Please Sign in or register to post replies

Write your reply to:

Draft