Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am trying to iterate over a list of child content and show the name and the image.
var dishwasherProducts = Model.Content.Site().FirstChild("dishLandingPage").Children() .Where(x => x.GetPropertyValue<string>("category") == "Dish") .Where(x => x.GetPropertyValue<string>("subCategory") == "dish - dishwasher") .Where(x => x.IsVisible());
But when I try to show the image I can't figure out how to do it.
@foreach(var item in dishwasherProducts){ <li> <a href="@item.Url"> @item.GetPropertyValue("productName") <img src="@Umbraco.TypedMedia(item.GetPropertyValue("image")).Url" alt="@item.GetPropertyValue("productName")" /> </a> </li> }
It works fine if I hard code a media ID like
<img src="@Umbraco.TypedMedia(1141).Url" alt="@item.GetPropertyValue("productName")" />
And if I just output the image I get the media ID like
@item.GetPropertyValue("image")
Hi Leo.
Try the following:
var media = item.GetPropertyValue<IPublishedContent>("image"); <img src='@media.Url'>
Best of luck to you!
Hello Leo,
I just finished that for my site, and here's the code that works for me:
<img src="@Umbraco.Media(item.GetPropertyValue("articlePhoto").ToString()).Url" alt="@Umbraco.Field(item,"metaTitle")">
So, you can replace some alias, and it will become:
<img src="@Umbraco.Media(item.GetPropertyValue("image").ToString()).Url" alt="@Umbraco.Field(item,"productName")">
I hope it will work for you too.
Good luck!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to display child image from query
I am trying to iterate over a list of child content and show the name and the image.
But when I try to show the image I can't figure out how to do it.
It works fine if I hard code a media ID like
And if I just output the image I get the media ID like
Hi Leo.
Try the following:
Best of luck to you!
Hello Leo,
I just finished that for my site, and here's the code that works for me:
So, you can replace some alias, and it will become:
I hope it will work for you too.
Good luck!
is working on a reply...