I'm having some trouble checking if my value is null in my image collection.
@foreach(dynamic img in Model.Children) { if(img.kollektion.ToString() != "") { foreach(dynamic d in img.kollektion.mediaItem) { if (d.BaseElement.Name == "Image") { <img src="@d.umbracoFile" /> } else { <img src="@d.Image.umbracoFile" /> } } } else { <span>No images selected</span> } }
I can't get this to work. I'm guessing it has something to do with the first foreach checking for children. My image collection is on the current page.
This works fine.
@foreach(dynamic d in Model.kollektion.mediaItem) {
Checking if image is null
Hi!
I'm having some trouble checking if my value is null in my image collection.
@foreach(dynamic img in Model.Children)
{
if(img.kollektion.ToString() != "")
{
foreach(dynamic d in img.kollektion.mediaItem)
{
if (d.BaseElement.Name == "Image")
{ <img src="@d.umbracoFile" /> }
else
{ <img src="@d.Image.umbracoFile" /> }
}
}
else
{ <span>No images selected</span> }
}
I can't get this to work. I'm guessing it has something to do with the first foreach checking for children. My image collection is on the current page.
This works fine.
@foreach(dynamic d in Model.kollektion.mediaItem)
{
if (d.BaseElement.Name == "Image")
{
<img src="@d.umbracoFile" />
}
else
{
<img src="@d.Image.umbracoFile" />
}
}
Can anyone please help :)
Thanks / Niklas
is working on a reply...