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
Hi!
I'm using razor to display lists with blog posts and news items. Some of them have cropped images (optional) and I need a way to check if a blog post or news item has a cropped image or not.
I use this code to display an image:
<img src="@item.imageCrop.Find("@name", "Liggande bild").url" alt="@item.name" />
In this case @item is the node I get in a foreach loop. How do I check if there is a cropped image or not using razor?
Regards,Thomas
Found something that seems to work fine:
@if (@item.HasValue("imageCrop")) { <img src="@item.imageCrop.Find("@name", "Liggande bild").url" alt="@item.name" /> }
Does anyone see a problem with this? Let me know!
/Thomas
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Checking for empty image crop using razor
Hi!
I'm using razor to display lists with blog posts and news items. Some of them have cropped images (optional) and I need a way to check if a blog post or news item has a cropped image or not.
I use this code to display an image:
In this case @item is the node I get in a foreach loop. How do I check if there is a cropped image or not using razor?
Regards,
Thomas
Found something that seems to work fine:
Does anyone see a problem with this? Let me know!
/Thomas
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.