... the result is some 4 digit value. I assume some sort of ID for this item. ie: Useless..
I can't work out how to display the selected image in my template. I have been on the forums and searching google for the last few hour and none of the 'solutions' with their 'inline-xlst', worked.
I would have thought that by version 6 of Umbraco, adding an media image to a template for display on a page is a snap. Maybe it is. I just don't know how to do it.
Ok. After a bit of reading I know about MVC mode.. I don't have time right not to convert the site to MVC so I can run this one line to display an image.
Displaying an image added as a media item
I'm using Umbraco 6 on a project.
I used the Media area to upload an image for use on a page.
Next I created a document type and specified one of the fields to be a Media Picker.
When I created one of these pages I am able to use the media picker to pick the image I want to display.
The problem starts in the template.
If I just put this element on the page
... the result is some 4 digit value. I assume some sort of ID for this item. ie: Useless..
I can't work out how to display the selected image in my template. I have been on the forums and searching google for the last few hour and none of the 'solutions' with their 'inline-xlst', worked.
The last one I tried... This one...
... returned
<img src="" />
I need help.
I would have thought that by version 6 of Umbraco, adding an media image to a template for display on a page is a snap. Maybe it is. I just don't know how to do it.
By razor code:
<img src="@Umbraco.TypeMedia(Model.Content.GetPropertyValue("titleBanner")).GetPropertyValue("umbracoFile")"/>
Thanks for this snippit of code :)
Owen
I dropped your line of code into my template and ran the site.
No image appeared.
What gets output to the browser when I look at the source code of the page is...
<img src="@Umbraco.TypeMedia(Model.Content.GetPropertyValue("titleBanner")).GetPropertyValue("umbracoFile")"/>
Looks to me that my template is no parsing the razor syntax.. Is that possible?
To Brad, Are you in MVC mode? You can't use it in WebForm mode directly.
Have a try:
<umbraco:Macro runat="server" language="cshtml">
<img src="@Umbraco.TypeMedia(Model.Content.GetPropertyValue("titleBanner")).GetPropertyValue("umbracoFile")"/>
</umbraco:Macro>
Or use a macro instead
Owen
You might be on to something.. MVC Mode?
When I tried your latest code bit, this was output to the browser
Update:
Ok. After a bit of reading I know about MVC mode.. I don't have time right not to convert the site to MVC so I can run this one line to display an image.
So for now, how do I do this without Razor?
is working on a reply...