Copied to clipboard

Flag this post as spam?

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


  • Madde 6 posts 26 karma points
    Jul 08, 2011 @ 13:42
    Madde
    0

    Display images from media picker

    Hi

    I have problems displaying images that i have uploaded from the media picker.

    this is not working: <img src="<umbraco:Item field='modellbild' runat='server'></umbraco:Item>" alt=""/>

    I tired this but it's not working: http://forum.umbraco.org/yaf_postst6956_Using-the-media-picker-and-uploader-to-add-images.aspx

    where do i get the imgAlias casuse the id isn't working

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jul 08, 2011 @ 13:52
    Tom Fulton
    0

    Hi,

    The Media Picker stores the ID of the image.  To get the image URL you'll need to use the helper function GetMedia.  It's usually best to do this from a macro (example on Lee's blog), but if you wanted you should be able to use Inline XSLT on the Item tag to achieve this:

    <img src='<umbraco:Item field="modellbild" runat="server" Xslt="umbraco.library:GetMedia({0},false())/umbracoFile"></umbraco:Item>' alt=''/>

    Hope this helps,
    Tom

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jul 08, 2011 @ 14:03
    Jeroen Breuer
    0

    If you want to store all the data of a media item you should try the Digibiz Advanced Media Picker.

    Jeroen

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Jul 09, 2011 @ 19:18
    Bjarne Fyrstenborg
    1

    Hi..

    Much similar Toms suggestion, I often use this to display an image selected from the Media Picker:

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

    Bjarne

  • Bert 128 posts 251 karma points
    Jul 09, 2011 @ 20:25
    Bert
    0
    //Get the Image
    var theImage = @Model.Media("modellbild");
    if (theImage != null)
    {
       <img src='@theImage.UmbracoFile' alt='@theImage.Name' />
    }

    The Razor way

  • Madde 6 posts 26 karma points
    Jul 11, 2011 @ 09:01
    Madde
    0

    Thank you all guys, now it's working.

    Tom Fulton asware is the first right one.

  • Arie 224 posts 675 karma points
    May 01, 2014 @ 03:19
    Arie
    1

    Since this thread showed up on a Google search I figured I'd add a solution for Umbraco 6. Might work in 4.x also, and probably does work in 7.x.

    <umbraco:Image field="mainImage" runat="server" />
    
  • Jon Benedict 4 posts 25 karma points
    Mar 18, 2015 @ 17:51
    Jon Benedict
    0

    Thanks Tom Fulton, Your solution worked great for me. This code can be pasted right into your template where you want the image to be. Just simply replace "modellbild" with the alias of your media picker and everything should work fine. This has worked for me in a number of umbraco versions, the latest I have tried being 7.2.2. Hopefully this helps someone who is struggling with a similar issue.

    <img src='<umbraco:Item field="modellbild" runat="server" Xslt="umbraco.library:GetMedia({0},false())/umbracoFile"></umbraco:Item>' alt=''/>


Please Sign in or register to post replies

Write your reply to:

Draft