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 pulling af comma-separated list from a multiple media picker.This get's me: "1111,4444,8888".
I want to foreach the list (and skip the first image), so I can get the media URL's - I am doing that by splitting:
@foreach(var test in CurrentPage.images.Split(',').Skip(1)){ @test.Url }
I then get an Exception error:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'System.Array' does not contain a definition for 'Skip'
How can I use Skip(), Take() and so on, when I foreach a splitted comma-separated list?
Hi Ørskov Gruppen A/S,
Try to see the documentation about using the multiple media picker https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/Media-Picker. I think I would do it like this. So I add the skip to the foreach loop.
@if (CurrentPage.HasValue("caseStudyImages")){ var caseStudyImagesList = CurrentPage.CaseStudyImages.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); var caseStudyImagesCollection = Umbraco.Media(caseStudyImagesList); foreach (var caseStudyImage in caseStudyImagesCollection.Skip(1)) { <img src="@caseStudyImage.Url" style="width:300px;height:300px" /> }}
Hope this helps,
/Dennis
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Using Skip() on a string array
I am pulling af comma-separated list from a multiple media picker.
This get's me: "1111,4444,8888".
I want to foreach the list (and skip the first image), so I can get the media URL's - I am doing that by splitting:
@foreach(var test in CurrentPage.images.Split(',').Skip(1)){ @test.Url }
I then get an Exception error:
How can I use Skip(), Take() and so on, when I foreach a splitted comma-separated list?
Hi Ørskov Gruppen A/S,
Try to see the documentation about using the multiple media picker https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/Media-Picker. I think I would do it like this. So I add the skip to the foreach loop.
Hope this helps,
/Dennis
is working on a reply...