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 know this isn't really a DAMP issue but I hope someone here can help because I'm being a little thick in the head today.
I have a DAMP property which has been populated with a number of images.I want to select just the first one using Razor.
This code will loop through them and break after the first one but is a bit nasty.
foreach (dynamic d in item.images){ var image = d.Image; var url = image.umbracoFile; break; }
Thanks,
Matt
I think that you can just do this:
<img src="@item.images.Image.umbracoFile"/>
Jeroen
Thanks, but it doesn't seem to like that. :-(
Hmm do you get an exception? Maybe this:
<img src="@item.images[0].Image.umbracoFile"/>
Yes, script error.
That second one works though.
Funny because I tried that approach before, just didn't get it right obviously.
Thanks, Matt
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to select the first image with Razor?
I know this isn't really a DAMP issue but I hope someone here can help because I'm being a little thick in the head today.
I have a DAMP property which has been populated with a number of images.
I want to select just the first one using Razor.
This code will loop through them and break after the first one but is a bit nasty.
foreach (dynamic d in item.images)
{
var image = d.Image;
var url = image.umbracoFile;
break;
}
Thanks,
Matt
I think that you can just do this:
Jeroen
Thanks, but it doesn't seem to like that. :-(
Hmm do you get an exception? Maybe this:
Jeroen
Yes, script error.
That second one works though.
Funny because I tried that approach before, just didn't get it right obviously.
Thanks, Matt
is working on a reply...