Copied to clipboard

Flag this post as spam?

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


  • Neil Norpa 24 posts 44 karma points
    Apr 12, 2011 @ 22:33
    Neil Norpa
    0

    render image from media using media picker in Umbraco 4.5.2

    hi,

    This is probably a simple thing but it giving me a headache i think i need a rest

     

    basically am using 4.5.2 and have inserted a number of image within the media section all i need to know is how to render them in a template i keep geting the id in my img src.

     

    simples but busting my...

    king regards

     

    Neil.

     

  • Eran Meir 401 posts 543 karma points
    Apr 12, 2011 @ 22:48
    Eran Meir
    0

    you can't render them to a template without a macro
    here's an example for xslt

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/imageProperty, 0)" />
     img src="{$media/umbracoFile}" width="80" height="80" />

    Razor example

    @{
    dynamic image = new umbraco.MacroEngines.DynamicMedia(@Model.imageProperty);
    img src="@image.umbracoFile" width="80" height="80 />
    }

    add a "<" on the img string, the forum try to render them as img :)

  • Kim Andersen 1447 posts 2196 karma points MVP
    Apr 12, 2011 @ 23:04
    Kim Andersen
    0

    Hi both of you

    Actually, yes you can render the image in your templates. You can do like this:

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

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft