Umbraco 7 - Showing media picker image in a template
can someone please supply me with the require code to display an image from a media picker "featureImage" inside a template. i am guessing it is very simple but i just cant figure it out ...
There is documentation here that shows how to output images from a multiple media picker which is new to v7. Or for a single media picker you can see the sample code here which is the same on v6 and v7 (look at the MVC section)
Essentially you need this snippet
@{
if (CurrentPage.HasValue("featureImage")){
var dynamicMediaItem = Umbraco.Media(CurrentPage.featureImage);
<img src="@dynamicMediaItem.umbracoFile" alt="@dynamicMediaItem.Name"/>
}
}
Umbraco 7 - Showing media picker image in a template
can someone please supply me with the require code to display an image from a media picker "featureImage" inside a template. i am guessing it is very simple but i just cant figure it out ...
here is my html code
<div class="banner_dish">
@Umbraco.Field("featureImage")
<div class="banner_dish_heading">
<h3>@Umbraco.Field("featureHeading") </h3>
<p>@Umbraco.Field("featureIntro")</p>
</div>
.............
I tried this code but it didnt work ...
@if (string.IsNullOrWhiteSpace(CurrentPage.featureImage.ToString()) == false)
{
<img src="@CurrentPage.Url("featureImage")" alt="" />
}
.................
is there a manual somewhere that tells you how to do simple things like adding an image to a template
Hi Mark,
There is documentation here that shows how to output images from a multiple media picker which is new to v7. Or for a single media picker you can see the sample code here which is the same on v6 and v7 (look at the MVC section)
Essentially you need this snippet
Jeavon
thank you Jeavon you rock ... that worked ...
Awesome!
Actually, thinking about it, it's probably a little bit better to update to:
Thanks,
Jeavon
is working on a reply...