View Full Version : multiple random images for latest thread?
cyr0n_k0r
07-13-2004, 05:20 AM
http://www.lanschoolyard.com/upload/store/example2.jpg
If you look, you will notice that all 3 blocks have the same image. I am trying for a random image script.. and the problem is.. the same image is repeated.
Is there a way to make the latest threads module load up different random images?
BoNfiRe
07-13-2004, 06:29 AM
http://www.lanschoolyard.com/upload/store/example2.jpg
If you look, you will notice that all 3 blocks have the same image. I am trying for a random image script.. and the problem is.. the same image is repeated.
Is there a way to make the latest threads module load up different random images?
Try this ....
Open header include template in admin cp and add the following.....
<script language="JavaScript">
<!--
var theImages = new Array()
theImages[0] = 'image/path/name.ext'
theImages[1] = ''image/path/name.ext'
theImages[2] = 'image/path/name.ext'
theImages[3] = 'image/path/name.ext'
theImages[4] = 'image/path/name.ext'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}
//-->
</script>
Change each theImages[0] = 'image/path/name.ext' to match your image location/name
Then where you want the images to show add .....
<script language="JavaScript">
<!--
showImage();
//-->
</script>
Hope this helps ;)
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.