In Umbraco 4.7.1 you can easily get a random image from a folder in the media library. Assuming you have the id of your folder:
dynamic folder = Library.MediaById(1054);
var randomImage = folder.Children.Where("nodeTypeAlias = \"Image\"").Random();
In my example 1054 is the id of the folder containing the images. The where part is only needed if your folder can potentially contain non-image files.
Random image from gallery
I am currently pulling the first image from a gallery folder using
How could I do something like this
If you get the image gallery folder, you can get a random image with ImageGen.
http://our.umbraco.org/projects/website-utilities/imagegen
page 16 in the Documentation PDF.
Nice. Now, how do I get the folder? I'd assume something like
or
Neither of which is right
Hey Tony
Well that depends on your solution, and how you created your gallery.
I just assumed, that since you wrote "from a gallery folder using" you already had the path for your gallery.
Are you using some sort of gallery package ?
Sorr, my bad. Read that as "from a media folder". The only package being used is
In Umbraco 4.7.1 you can easily get a random image from a folder in the media library. Assuming you have the id of your folder:
is working on a reply...