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,
What i wanted to achieve is to get a single image in a random order from a media folder (by id)
This worked for in V7 (looking at previous projects), but now in V8 i'm stuck.
@{ var galleryAlbum = Umbraco.Media(1210); foreach(var image in galleryAlbum.Children.RandomOrder().Take(1)){ <div class="parallax-window" data-parallax="scroll" data-image-src="@Url.GetCropUrl(image, "Hero")"></div> } }
Could someone help me out?
Hi Peter
What about this approach:
var galleryAlbum = Umbraco.Media(1210); var theList = galleryAlbum.Children.ToList(); var randomImage = theList.ElementAt(new Random(DateTime.Now.Millisecond).Next(theList.Count()));
Thank you very much! Exactly what i wanted .
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
Get an image (random) from a media folder
Hi,
What i wanted to achieve is to get a single image in a random order from a media folder (by id)
This worked for in V7 (looking at previous projects), but now in V8 i'm stuck.
Could someone help me out?
Hi Peter
What about this approach:
Thank you very much! Exactly what i wanted .
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.