PDA

View Full Version : Photo Album script



suwii
10-28-2005, 07:39 AM
Script: Photo Album Script
http://www.dynamicdrive.com/dynamicindex4/photoalbum.htm

I'm a newbie at all this :P So I'm wondering how can you add pictures to pages 2,3,4 etc..?
And can you change the text 'Page1' 'Page2'?

jscheuer1
10-28-2005, 04:49 PM
You add pictures by adding to the array:


//Specify images:
//galleryarray[x]=["path_to_image", "optional_title_attribute", "optional_text_description", "optional_link"]
var galleryarray=new Array()
galleryarray[0]=["photo1.jpg", "optional title", "optional description", "optional url"]
galleryarray[1]=["photo2.jpg", "optional title", "optional description", "optional url"]
galleryarray[2]=["photo3.jpg", "optional title", "optional description", "optional url"]
galleryarray[3]=["photo4.jpg", "optional title", "optional description", "optional url"]
galleryarray[4]=["photo5.jpg", "optional title", "optional description", "optional url"]
galleryarray[5]=["photo6.jpg", "optional title", "optional description", "optional url"]
galleryarray[6]=["photo7.jpg", "optional title", "optional description", "optional url"]
galleryarray[7]=["added.jpg", "optional title", "optional description", "optional url"]

The actual number of images per page is controlled here:


var dimension="3x2" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc

So to add images to a particular page you need to increase the number of images shown per page. To get more control, dummy images may be inserted in the array using a transparent .gif, ex:


galleryarray[2]=["transparent.gif", "", "", ""]

These will appear as blank areas in the given 'page' that they fall on.

The text for 'Page1' 'Page2' is generated here on the red line:


<div id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.floor(galleryarray.length/totalslots+2); i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">Page'+i+'</a> ')
document.getElementById("navlink1").className="current"
</script>
</div>

To change the text displayed, you can edit it like so:


document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">Items'+i+'</a> ')

The above change will yield 'Items1', 'Items2', etc.

suwii
10-28-2005, 10:54 PM
thanks heaps!!!!
and if I could ask another question how do you get rid of the optional url?

jscheuer1
10-29-2005, 05:33 AM
The optional fields can be made to 'disappear' as it were, by simply using empty quotes for them in the array, for example:


galleryarray[0]=["photo1.jpg", "optional title", "optional description", "optional url"]

can become:


galleryarray[0]=["photo1.jpg", "optional title", "optional description", ""]

if no url is desired.

suwii
10-29-2005, 05:43 AM
great!! thx :)