{"id":1555,"date":"2008-06-10T23:55:31","date_gmt":"2008-06-11T04:55:31","guid":{"rendered":"http:\/\/teamtutorials.com\/?p=1555"},"modified":"2008-10-26T14:47:52","modified_gmt":"2008-10-26T18:47:52","slug":"professional-javascript-based-photo-viewer","status":"publish","type":"post","link":"https:\/\/teamtutorials.com\/web-development-tutorials\/professional-javascript-based-photo-viewer","title":{"rendered":"Professional Javascript Based Photo Viewer"},"content":{"rendered":"
This tutorial will walk you through installing and configuring Lightbox 2. Lightbox allows you to show your pictures on your site in a whole new light. It gives you a sleek and professional look and is VERY easy to implement. Lightbox is written by Lokesh Dhakar <\/a> and can be downloaded from HuddleTogeteher<\/a><\/p>\n <\/a><\/p>\n Once the site loads it should take you straight to the download section of the page. Click on it to download the files you need. They will come in.ZIP file.<\/p>\n <\/a><\/p>\n Save the file to your desktop or somewhere else that you will be able to get to it easily when it is completed.<\/p>\n <\/a><\/p>\n If you have WinRAR or some other program installed that will uncompress it you will be able to right-click on it and select uncompress to (file name here). <\/p>\n <\/a><\/p>\n This is what the files look like once you un-compressed them. For the easiest use, you should leave these files the way they are and upload them to your server. If you have a different layout you use on your server (for storing scripts and pictures) I will cover how to make those changes later.<\/p>\n Now we need to create our index.html file that will call these files and make them work. Please note that I added 4 files to the images directory with the names of image-2.jpg, image3.jpg, image4.jpg, and image5.jpg. I have also made the 4 extra thumbnails for them as well and named them accordingly. You can Download the Images.( www.teamtutorials.com\/images.zip)<\/p>\n Now let\u2019s look at our code to make this work:<\/p>\n The above lines simply tell the HTML file where to get the javascript to handle our pictures that we are using. It also says where to get our Cascading Style Sheet to format the output. <\/p>\n The above text is simple html to show the images. The only difference you will need to note is the \u201crel=lightbox[]\u201d area. Notice How the first ones say set1 and the second set say set 2. You can do this with any names you want to make separate sets. This way they can view all the pictures from one set and then go to the next set. If you just have one big set, you can leave the brackets blank. This should work now, as long as you set everything up the way it came in the zip file, if you moved any of the files, you will have to change a few things. One is the line in the html that calls the style sheet. If you have that somewhere else change that line and obviously the images your linking too will be different. If you have the javascripts somewhere else you need to change them in the HTML file as well. If you re-locate the images you need to change some things in the CSS and in one of the JS files.<\/p>\n In the CSS look for these two lines and change them accordingly to match where your images are:<\/p>\n In the lightbox.js file near the top look for these two lines and change them to match where you put your image files:<\/p>\n Other than that every thing should still work. If you have any troubles, ensure that your files are all located in the correct place. I find it simpler to make it work the way it came first, and then move it the way you wanted to make sure that you understand what changes you made. <\/a><\/p>\n When you click on one of the images from a set it should turn into this:<\/p>\n\r\n<html>\r\n<head>\r\n<link rel="stylesheet" href="css\/lightbox.css" type="text\/css" media="screen" \/>\r\n<script type="text\/javascript" src="js\/prototype.js"><\/script>\r\n<script type="text\/javascript" src="js\/scriptaculous.js?load=effects,builder"><\/script>\r\n<script type="text\/javascript" src="js\/lightbox.js"><\/script>\r\n<\/head>\r\n<\/pre>\n
\r\n<body bgcolor = \u201c666666\u201d>\r\n<font color ="FFFFFF">\r\n <H2> Set 1 <\/H2>\r\n<a href="images\/image-1.jpg" rel="lightbox[set1]" title="Set 1 Picture 1"><img src="images\/thumb-1.jpg"\/><\/a>\r\n\r\n<a href="images\/image-2.jpg" rel="lightbox[set1]" title="Set 1 Picture 2"><img src="images\/thumb-2.jpg"\/><\/a><br \/><br \/>\r\n\r\n <H2> Set 2 <\/H2>\r\n\r\n<a href="images\/image-3.jpg" rel="lightbox[set2]" title="Set 2 Picture 1"><img src="images\/thumb-3.jpg"\/><\/a>\r\n\r\n<a href="images\/image-4.jpg" rel="lightbox[set2]" title="Set 2 Picture 2"><img src="images\/thumb-4.jpg"\/><\/a>\r\n\r\n<a href="images\/image-5.jpg" rel="lightbox[set2]" title="Set 2 Picture 3"><img src="images\/thumb-5.jpg"\/><\/a>\r\n\r\n<\/body>\r\n<\/html>\r\n<\/pre>\n
\r\n#prevLink:hover, #prevLink:visited:hover { background: url(..\/images\/prevlabel.gif) left 15% no-repeat; }\r\n#nextLink:hover, #nextLink:visited:hover { background: url(..\/images\/nextlabel.gif) right 15% no-repeat; }\r\n<\/pre>\n
\r\nLightboxOptions = Object.extend({\r\n fileLoadingImage: 'images\/loading.gif', \r\n fileBottomNavCloseImage: 'images\/closelabel.gif',\r\n<\/pre>\n
\nIf the above code all works and you have the files in the correct place the main page should look like this:<\/p>\n