Im trying to get a media picker to work in a nested content. Its a simple nested content but i just cant seem to get the image to display.
my code is:
var items = Model.Value<IEnumerable<IPublishedElement>>("hrDoc");
foreach (var item in items)
{
var name = item.Value<string>("sectionTitle");
var image = item.Value<IPublishedContent>("media");
<h1>@name</h1>
if (image != null)
{
<a href="@image.Url"> </a>
}
}
it displays the title but item only seems to have sectionTitle when i debug. Items has both sectionTitle and media.
Thank you that worked however i put the if before the foreach as i was getting a null exception as the foreach before that there is no image only the last count. which is set in my umbraco content. Thank you for this!
Media picker in nested content
Im trying to get a media picker to work in a nested content. Its a simple nested content but i just cant seem to get the image to display. my code is:
it displays the title but item only seems to have sectionTitle when i debug. Items has both sectionTitle and media.
if anyone can help that would be great. Thank you
Hi Jamie,
Are you sure it is a single media picker?
If you want to display images from multiple media picker, you could try getting an Enumerable of images:
~ Jonathan
Thank you that worked however i put the if before the foreach as i was getting a null exception as the foreach before that there is no image only the last count. which is set in my umbraco content. Thank you for this!
is working on a reply...