Copied to clipboard

Flag this post as spam?

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


  • siva 5 posts 25 karma points
    Sep 18, 2012 @ 12:17
    siva
    0

    Media Picker Image in template file without using xslt or razor

    can someone help how to show image that is added from mediapicker in a template file without using xslt and razor..

    am using umbraco v 4.8.1..

  • siva 5 posts 25 karma points
    Sep 18, 2012 @ 12:23
    siva
    0

    am having same issue as shown in this page

    http://our.umbraco.org/forum/templating/templates-and-document-types/10542-Displaying-images-in-Template-from-Media-Picker

    am getting image tag with no source like <img src="" />

  • siva 5 posts 25 karma points
    Sep 18, 2012 @ 12:55
    siva
    0

    this is the solution, its very simple..

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

  • Warren 30 posts 95 karma points
    May 16, 2013 @ 04:31
    Warren
    0

    Hi Siva

    That solution works. Many thanks.

    Is there a razor way of doing it? (I dont know any xslt, and I am more comfortable using razor)

    Thanks

  • Warren 30 posts 95 karma points
    May 16, 2013 @ 23:10
    Warren
    0

    OK Here is the way to do it in razor, using inline razor code.

    Where "contentMediaImage" is the name of your Media Picker field.

     

                    <umbraco:Macro runat="server" Language="cshtml">              
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
    if (Model.contentMediaImage != "")
    {
    var media = Library.MediaById(Model.contentMediaImage);
    <img src="@media.umbracoFile"  />
    }
    }
    </umbraco:Macro>

     

Please Sign in or register to post replies

Write your reply to:

Draft