Here's a quick little "random image" custom island that can be used/modified. Just displays a single random image that links to the the actual gallery post:

Code
/* PHP CODE HERE */

$query = "
select POST_ID,FILE_DIR,FILE_NAME
from ubbt_FILES
where FILE_DIR <> ''
order by rand() limit 1
";
$sth = $dbh->do_query($query,__LINE__,__FILE__);
list($postId,$fDir,$fName) = $dbh->fetch_array($sth);
/* BODY HERE */
$body = <<<EOF
<div style='text-align: center'>
<a href="{$config['BASE_URL']}/ubbthreads.php?ubb=showgallery&Number=$postId">
<img border="0" src="{$config['BASE_URL']}/gallery/$fDir/thumbs/$fName" />
</a>
</div>
EOF;