I'm trying to setup a simple site during evaluating Umbraco. I have a template with a "Media Picker" Content Type and would like to display the image that the user has chosen in the template.
If I put the following code in the template: <umbraco:Item runat="server" field="imagecontent"/>
Then it displays the ID of the image (I'm assuming). I've been trying to read up on the various ways of doing it and most are centered around creating an external XSLT file etc. or a macro. Is it not possible just to put something simple inline into the template to display the image?
I've looked around and it appears that there should be a solution which is as follows:
When inserting an umbraco page field, there is also an option to add tag before and after. I know it works in version 4. I don't know if it's different in 4.5.
Displaying images in Template from Media Picker
Hi Guys,
I'm trying to setup a simple site during evaluating Umbraco. I have a template with a "Media Picker" Content Type and would like to display the image that the user has chosen in the template.
If I put the following code in the template: <umbraco:Item runat="server" field="imagecontent"/>
Then it displays the ID of the image (I'm assuming). I've been trying to read up on the various ways of doing it and most are centered around creating an external XSLT file etc. or a macro. Is it not possible just to put something simple inline into the template to display the image?
I've looked around and it appears that there should be a solution which is as follows:
< umbraco:Item runat="server" field="imagecontent" xslt="concat('<img src="', umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '" />')" xsltDisableEscaping="true" />
But it just returns: <img src="" />
Is there a quick and easy way or do I really have to create a seperate xslt file for every image I want to put in the template?
Any help would be appreciated.
Thanks, Craig
Hi Craig
Are you using 4.5? If so the xml schema is a little different - try this
Dan
YOU BEAUTY!
Thanks Dan! :) That was it, all the documentation I was looking at was for 3.0 by the looks of it! :)
Cheers Bud! :)
Craig
When inserting an umbraco page field, there is also an option to add tag before and after. I know it works in version 4. I don't know if it's different in 4.5.
It will look something like this.
<umbraco:Item field="Image" insertTextBefore="<img src="" insertTextAfter="">" runat="server"></umbraco:Item>
Dan
danielcruger.com
is working on a reply...