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.
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. :)
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>
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
Try this instead:
<umbraco:item runat="server" field="icon" xslt="concat('<img src="',umbraco.library:GetMedia({0}, true())/umbracoFile, '" border=0 />')" xsltdisableescaping="true" />
Wicked, thanks a lot David, perfect!
Just need to get the text to sit next to it now and all is good.
Thanks again!
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
is working on a reply...