Main
Main Page]-
Site Information]-
Forums]-
Simple Javascript Image Gallery]-
Javascript Image Scale Tool]-
MindaMusic.com Scam]-
Because of how this image gallery was designed, the page reloads every time you go to a new image. This has some good and bad effects. It's good if you have ads showing and want them refreshed for every pageview, but it could potentially be bad if you plan to incorporate this script into a large HTML file. Another benefit of this design though is the ability to link to any image directly and have it treated like it's own unique resolvable url, so http://blank.me/image-gallery/?i=1 is different from http://blank.me/image-gallery/?i=2 as far as search engines and browsers are concerned.

Filename Standards:

Image file names, paths, and extensions are assumed to be:
1. Uniform except for one variable which is a number.
2. In order without skipping a number. (The start and end number is defined by the settings.)

There are three parts to the file name, the prefix, number, and extension.
The prefix is everything in the image's URL BEFORE the number variable.
The extension is everything in the image's URL AFTER the number variable.

example 1: "http://www.com/path/to/imageXsmall.jpg"
prefix="http://www.com/path/to/image"
number="X" (variable)
extension="small.jpg"

example 2: "../images/pets/X.jpg"
prefix="../images/pets/"
number="X" (variable)
extension=".jpg"

I have a windows batch file made up to rename images automatically, not guaranteed to work for you (always make backups!), but you can download it here.

Lets look at the sample source files: HTML File | Script File | Description File

A completely functional gallery HTML page can be as simple as this:




or even this:






Now lets break that up into it's components. First up we have the settings. I put the settings in the HTML file so you can use the same script for multiple galleries and have different settings for each one.

This gets updated and placed into the head area of the HTML file:





You don't have to have all the comments in the settings, you can reduce them like so:





We reference the file that controls the images being displayed next. Copy this line to the head area of the HTML file, then update the "src=" to where you placed the simple.js file on your server. You can rename the file if you want, it won't cause any problems.




If you have Descriptions generated and turned on in the options, we can now reference the file that contains those. Copy this line to the head area of the HTML file, then update the "src=" to where you placed the file containing the descriptions. If you don't want descriptions, don't bother to include this file.

I put the descriptions in a seperate file so it doesn't get downloaded completely each and every time a new image is loaded. This would mostly benefit larger galleries with long descriptions.




We need to update the image when the page loads, so we make sure the body tag has an onload parameter on it like so:




Navigation links. You can customize these as you wish.

The script works by adding the number you specify to the current image number, then displays that image number. If the number is not within the valid range, it loops back to the beginning or end of the valid range. That is why I have the "first" link setup like it is, 999999 is larger than the valid range, so it loops back to the first image in the range. The "last" link is just the reverse of the "first" link.




Image numbers. This is a placeholder div the script uses to display the image numbers if you have them enabled in the settings. This div doesn't need to be included if you have the image numbers disabled. The ID needs to match the ID in the settings, and the ID must be unique for the entire HTML file.

The basic output is similar to "1 of 22"




Placeholder image. This is a 1x1px transparant image that acts as a placeholder. The script updates the source of the image depending on which image you are currently asking it to load. I also put a link around the image so you can just click on it to go to the next one.

Download the transparant image here. (Right click and save as.)




Description. This is a placeholder div the script uses to display the image description if you have them generated and enabled in the settings. This div doesn't need to be included if you have the descriptions disabled. The ID needs to match the ID in the settings, and the ID must be unique for the entire HTML file.