Get URL of media picker property of all children in a foreach loop
Hi,
I am trying to display images from child nodes in the parent page by getting the media picker value (id of media image) within a foreach loop for each child, but it just returns the mediatype - Umbraco.Web.PublishedModels.Image*
@foreach (var group in Model.Children.InGroupsOf(4))
{
<div class="row">
@foreach (var item in group)
{
<img src="@Umbraco.Media(item.Value("summaryImage")).GetCropUrl("SummaryImageCrop")" />
}
</div>
}
The problem seems to be that @item.Value(propertyAlias) does not return the ID.
Get URL of media picker property of all children in a foreach loop
Hi,
I am trying to display images from child nodes in the parent page by getting the media picker value (id of media image) within a foreach loop for each child, but it just returns the mediatype - Umbraco.Web.PublishedModels.Image*
The problem seems to be that @item.Value(propertyAlias) does not return the ID.
Can anyone see what I am doing wrong please?
Hi Dominic,
which version of Umbraco do you use?
Maybe item.Value("summaryImage") contains already the converted IPublishedContent Object instead the Id. Can you try, if
without @Umbraco.Media works for you?
Best, Sören
Thanks - I am using V8.
But GetCropUrl method is not available
Trying
@item.GetCropUrl("summaryImage","SummaryImageCrop")
returnsUmbraco.Web.PublishedModels.Imagemode=pad&rnd=131959248365800000
This worked..
is working on a reply...