This now returns a random recent image :smile:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
function chooseAlbum() {
global $cache;
/*
* The odds that an album will be selected is proportional
* to the number of (visible) items in the album.
*/
$total = 0;
foreach ($cache as $name => $count) {
$album = new Album();
$album->load($name);
$time = $album->fields["last_mod_time"];
if ($time > $curdate && rand(1,3) == 2) {
$choose = $name;
$curdate = $time;
}
}
if ($choose) {
$album = new Album();
$album->load($choose);
return $album;
} else {
return null;
}
}
</TD></TR></TABLE><!-- BBCode End -->