In plugins/lazy-gallery/lazy-img.php, replace the initial call to generateImg with this code:
if ($_GET['random']) {
$files=array();
get_dir_contents($files, $gallery_root);
foreach ($files as $file) {
//echo $file.'<br/>';
}
generateImg($files[array_rand($files)], $_GET['thumb']);
} else {
generateImg($gallery_root.$_GET['file'], $_GET['thumb']);
}
function get_dir_contents(&$files, $dirname) {
$handle=opendir($dirname);
while ($file = readdir($handle)) {
if($file=='.'||$file=='..') {
continue;
}
$full_name = $dirname.'/'.$file;
if(is_dir($full_name) && !in_array($file, get_option("lg_excluded_folders")) ) {
get_dir_contents($files, $full_name);
} else {
if (is_image(pathinfo($full_name))) {
$files[]=$full_name;
}
}
}
closedir($handle);
}
function is_image($file_info) {
switch(strtolower($file_info["extension"])) {
case "jpeg":
case "jpg":
case "gif":
case "png":
return true;
default:
return false;
}
}
Then in plugins/lazy-gallery.php put:
function getRandomLazyImage($thumb = 1, $rotate = 0) {
$src = get_settings('siteurl').'/wp-content/plugins/lazy-gallery/lazy-img.php?random=1&thumb='.$thumb;
srand((double)microtime()*1000000);
$randSuffix = rand(0,100);
$imgHTML = '<div class="img-shadow" id="divRandomLazyImage'.$randSuffix.'"><img id="randomLazyImage'.$randSuffix.'" src="'.$src.'" /></div>';
if ($rotate == 1) {
$imgHTML = $imgHTML.' <script type="text/javascript">function refreshLazyImage'.$randSuffix.'() { var rnd = Math.random()*100; document.getElementById('randomLazyImage'.$randSuffix.'').src="'.$src.'&joe="+rnd; blendimage('divRandomLazyImage'.$randSuffix.'', 'randomLazyImage'.$randSuffix.'', ''.$src.''+rnd, 2500); window.setTimeout(refreshLazyImage'.$randSuffix.', Math.random()*5000+3000);} refreshLazyImage'.$randSuffix.'();</script>';
}
return $imgHTML;
}
Then add
<script src="/your_web_path/wp-content/shared/fader.js" type="text/javascript"></script> to your theme's index.php
You can get the file here:
http://www.xyooj.com/blog/wp-content/shared/fader.js.txt
Finally, put getRandomLazyImage(1, 1) anywhere you want the random image to go (you can call it more than once to have more than one random image displayed).
Again, the first parameter value of 1 indicates that you want a thumbnail instead of a larger image. The second 1 indicates that you want it to automatically load a new random image.
Happy blogging.