TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 09:30:20 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 92
  • Total: 92

Random Photo display

Started by juggler, January 07, 2006, 12:28:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

juggler

OK it's not a coppermine tie in and does mean you'll have to upload the photos to a directory your self. I've used this script on my site for a "Rogues Gallery" of members of the forum. It also allows you to have each photo link to a website individually as well (Although mine all point to my gallery at the moment). To see it in action drop by www.bluebuzzards.com/buzzards.

<script language="JavaScript">
<!--

/*
Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com)
Over 200+ free JavaScripts here!
Updated: 00/04/25
*/

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="http://www.bluebuzzards.com/tpimages/Image1.jpg"
myimages[2]="http://www.bluebuzzards.com/tpimages/Image2.jpg"
myimages[3]="http://www.bluebuzzards.com/tpimages/Image3.jpg"
myimages[4]="http://www.bluebuzzards.com/tpimages/Image4.jpg"
myimages[5]="http://www.bluebuzzards.com/tpimages/Image5.jpg"


//specify corresponding links below
var imagelinks=new Array()
imagelinks[1]="http://www.bluebuzzards.com/gallery"
imagelinks[2]="http://www.bluebuzzards.com/gallery"
imagelinks[3]="http://www.bluebuzzards.com/gallery"
imagelinks[4]="http://www.bluebuzzards.com/gallery"
imagelinks[5]="http://www.bluebuzzards.com/gallery"



var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}
random_imglink()
//-->
</script>

<p align="center"><font face="arial" size="-2">This free script provided by</font>

<font face="arial, helvetica" size="-2">JavaScript
Kit
</font></p>

crip


crip

Handy link to this useful image script |Randomised|


jackgordon


scope

OK, I have the random display of pics setup, but I don't want to resize each picture I put on.  What is the right html code to add to the javascript/html box to get a size in there.   I currently have the following:

<table>
<tr >
  <td width="50"  length="50">
<p></p>
<script language="JavaScript">
<!--

/*
Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com)
Over 200+ free JavaScripts here!
Updated: 00/04/25
*/

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="../pics/1.jpg"
myimages[2]="../pics/2.jpg"
myimages[3]="../pics/3.jpg"
myimages[4]="../pics/4.jpg"
myimages[5]="../pics/5.jpg"
myimages[6]="../pics/6.jpg"

//specify corresponding links below
var imagelinks=new Array()
imagelinks[1]=""
imagelinks[2]=""
imagelinks[3]=""
imagelinks[4]=""
imagelinks[5]=""
imagelinks[6]=""

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}
random_imglink()
//-->
</script>
     </td>
</tr>
<p></p>
<tr>
     <td>
<p align="center"><font face="arial" size="-2">This free script provided by</font>

<font face="arial, helvetica" size="-2">JavaScript
Kit
</font></p>
    </td>
</tr>
</table>

As you can see I created tables and it still doesn't seem to work.  Any suggestions or anytihng you notice I did wrong.

crip

If you have thumbnails to a for each image; just link the random ones to the full size images..i'm pretty sure you need thumbnails as the random in the script/html block..

DJRONY

#6
That won't make any good if I have 100 pictures or more. I have to link up all the images..?


JPDeni

If you want the photos linked to external websites, then, yes, you would have to create links for the images. If you want something else, maybe not.