WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: YoJoe on May 27, 2011, 01:42:36 AM

Title: RandomImage also from subfolders
Post by: YoJoe on May 27, 2011, 01:42:36 AM
Since randomimage droplet uses a readdir() function, I'm wondering if it would be much hassle to change its algorithm to use scandir(), to also draw an image from nested directory.
The main reason is to show randomly chosen image on index page from existing image galleries.

The best way would be to scandir() for all directories in root directory, choose a random subdirectory and then choose a random img from it. Because scanning all subdirs, and loading all img files would take unnecessary time and resources only to grab, and show 1 photo.

There wouldn't be much a problem with nested dirs with images named like:
subdir1
subdir2
...
because it would be a simple change in droplet.
But nested directories are going to have random names, and that's too much for my rookie php skills :/