Copied to clipboard

Flag this post as spam?

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


  • Pat 56 posts 147 karma points
    Jan 14, 2012 @ 19:12
    Pat
    0

    Images not showing, just IDs

    Hey,

    I have looked through the search results here, but nothing I have tried has worked.

    I have three DIVs on my home page, each containing a service each. In there, there should be an image, it is defined as a media picker data type and the image is chosen from the directory, but it just shows the image ID on the page when I call it through. Have hardcoded image in atm using html, but I want to have it via the content tab as it is cleaner and easier.

    Any help appreciated. :)

  • David W. 159 posts 284 karma points c-trib
    Jan 14, 2012 @ 19:58
    David W.
    0

    How exactly are you trying to display the image? From a template?

    I use this (where "image" is the MediaPicker property):

     

    <umbraco:macro runat="server" language="cshtml">

                @inherits umbraco.MacroEngines.DynamicNodeContext
                @if (Model.HasProperty("image") && Convert.ToString(Model.image) != "") {
                    <img src='@Model.Media("image", "umbracoFile")'  />
                }

            </umbraco:macro>

  • Pat 56 posts 147 karma points
    Jan 14, 2012 @ 20:03
    Pat
    0

    At the moment I am just calling the Umbraco field. <umbraco:Item field="icon" runat="server" />

    However, previously I had this and also a load of different getMedia code and nothing seemed to work at all. Just with the above it shows the image ID

  • David W. 159 posts 284 karma points c-trib
    Jan 14, 2012 @ 20:09
    David W.
    100

    Try this instead:

    <umbraco:item runat="server" field="iconxslt="concat('&lt;img src=&quot;',umbraco.library:GetMedia({0}, true())/umbracoFile, '&quot; border=0 /&gt;')" xsltdisableescaping="true" />

  • Pat 56 posts 147 karma points
    Jan 14, 2012 @ 20:30
    Pat
    0

    Wicked, thanks a lot David, perfect!

    Just need to get the text to sit next to it now and all is good.

    Thanks again!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 15, 2012 @ 12:52
    Jeroen Breuer
    0

    If you want to have more info about GetMedia have a look at this wiki: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia.

    If you use DAMP you can also get the media as xml instead of just the id.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft