Just in case anyone is interested, here's what I put together:
On the admin -> options -> theme options page I now have a list with all albums (subalbums included) to choose from + an option to select the entire gallery.
[b]`In themeoptions.php:`[/b]
function ThemeOptions() {
setOptionDefault('Allow_comments', true);
setOptionDefault('Allow_search', true);
[b]added [/b] `'setOptionDefault('Randomimage, 'Gallery');'`
}
function getOptionsSupported() {
return array(
gettext('Allow comments') => array('key' => 'Allow_comments', 'type' => 1, 'desc' => gettext('Check to enable comment section.')),
gettext('Allow search') => array('key' => 'Allow_search', 'type' => 1, 'desc' => gettext('Check to enable search form.')),
[b]added[/b]
`gettext('Randomimage') => array('key' => 'Randomimage', 'type' => 2, 'desc' => gettext('Select source for random image')),`
}
function handleOption($option, $currentValue) {
switch ($option) {
case 'Theme_colors':
$theme = basename(dirname(__FILE__));
$themeroot = SERVERPATH . "/themes/$theme/styles";
echo '<select id="themeselect" name="' . $option . '"' . ">\n";
generateListFromFiles($currentValue, $themeroot , '.css');
echo "</select>\n";
break;
[b]added[/b]
`case 'Randomimage':
$albumlist = query_full_array("SELECT folder FROM ".prefix('albums'));
foreach ($albumlist as $album) $list[] = $album['folder'];
$list[] = '--Gallery--';//add option for entire gallery to array
echo '<select id="themeselect" name="' . $option . '"' . ">\n";
generateListFromArray(array(getOption('Randomimage')), $list, false, false);
echo "</select>\n";
break;`
}
}
[b]on thepageyouwant.php add:[/b]
`
<?php if ((getOption('Randomimage')== '--Gallery--')) {
makeImageCurrent(getRandomImages(false)); printCustomSizedImageMaxSpace($alt='',600,600,NULL,NULL, false); } // displays a random image from the entire gallery
else {
makeImageCurrent(getRandomImagesAlbum(getOption('Randomimage'))); printCustomSizedImageMaxSpace('',600,600,NULL,NULL, false);} ?>
//displays a random image from any other chosen album
`
This is probably not the most elegant way to do it but it works.
There is still an issue with changing the image description in the frontend. Not sure why.
Thanks to sbillard for setting me on the right track!