This tip applies to HTML templates. In case you use a CMS, you should rather use one of the available extensions.
The Lightbox effect is a really cool Artisteer feature that enables you to enrich your projects with image galleries. But Artisteer's Lightbox is not as impressive as the real one. Wouldn't it be nice to have a gallery with the real Lightbox? In this tip, I will show you how to modify the code, to get the gallery with real Lightbox. In this example, we will use the betterImageGallery.artx
project file.
Lightbox is the generic name for the group of techniques that display images using modal dialogs. The name comes from original JavaScript plugin, created by Lokesh Dhakar (for more information, visit http://lokeshdhakar.com/projects/lightbox/). Lightbox-like scripts show images in a nice border, with navigation controls and description text.
We will use the Lightbox2 effect, based on the jQuery library. There are many Lightbox-like effects available, but this one is quite powerful and easy to use. Artisteer uses jQuery for its own Lightbox effect and attaches this library to exported projects by default, so it is a good idea to use an effect based on this library. Here is our procedure:
Lightbox
folder.galleryImages.zip
file. You should have the galleryImages
folder with eight simple images inside.betterImageGallery.artx
project file. You will see that it's just a one-page template, with eight empty cells in the content area. The concept of an image gallery using Lightbox is that the thumbnails of images are displayed on the page. Each thumbnail is a link to the corresponding big image. Without Artisteer, we would need to prepare thumbnails of our images, but we don't have to worry about this, as Artisteer will correctly resize each image while inserting them into cells.ImageGallery
. Open this folder and double-click on the index.html
file to view the site in the browser.index.html
file to display our site in the browser. Make sure that the Lightbox effect is disabled for any thumbnail in our gallery. If you have missed to disable this effect for any picture, go back to Artisteer, disable it, and export the project one again, overwriting the previously exported files.images
folder. This is the standard Artisteer-generated template folder that contains all the graphic files used in the project. Notice that while inserting the image into our project, Artisteer did not only adopt the size of the original image to the target dimensions (cell), but also made a copy with a thumbnail. We now have two copies of each image of our gallery, that is, a thumbnail (that is actually displayed in cell), and its corresponding image, in the original size. The naming conventions of the generated images are as follows:
Thumbnail |
Original image (bigger one) |
---|---|
|
|
|
|
As all the image are stored in the images
folder, we need to start the path with the folder name according to the pattern Folder name/bigger-image-name
.
We are working with the 1.jpg
file (first thumbnail), so in this case, we should type images/1-large.jpg
.
Repeat this procedure for each image. Export the project again, overwriting the previously exported files.
If you have problems in this step (after clicking on the thumbnail, there is an error instead of the bigger image being displayed), go back to Artisteer, edit the Link properties, and make sure that the value of the Address: field doesn't begin with the /
character. If so, remove it. For some reason, if the address of a link starts with /
, Artisteer adds .html
to the address. For example:
images/1-large.jpg
/images/1-large.jpg
This is the first image of our gallery
as the description for the first image.Repeat the procedure, giving each image an appropriate description.
The last thing we can do in Artisteer is set up a correct rel
attribute for any link in our gallery. Lightbox2 works only with pictures that have the setting rel="Lightbox[galleryName]"
.
This feature makes it possible to have more than one gallery on a page. Each picture is displayed with navigation arrows, allowing the user to switch to the next or previous image.
galleryName
in square brackets identifies the image as belonging to a particular gallery. This name is up to you. If you have more than one gallery on your page, set a proper galleryName
in rel
attribute for every image. This will inform Lightbox where a particular gallery ends and where another one starts.
<a href="images/1-large.jpg" title="This is the first image of our gallery">
title
attribute and add in:rel="Lightbox[myGallery]"
<a href="images/1-large.jpg" rel="Lightbox[myGallery]"title="This is the first image of our gallery">
Lightbox
folder we prepared before to this folder. Then edit the index.html
file and find the part of the code where jQuery is attached. We are looking for the following line (near the beginning of the file):<script src="jquery.js"></script>
<!-- we add Lightbox effect --> <link rel="stylesheet" href="Lightbox/css/Lightbox.css" /> <script src="Lightbox/js/Lightbox.js"/> <!-- end of our modifications -->
index.html
file. Our gallery should work as expected, but the close and loading images are missing. To fix this, just copy or move the close.png
and loading.gif
files from the Lightbox/images
folder to our template images
folder (from the ImageGallery/Lightbox/images
directory to the ImageGallery/images
directory).That was the last thing to do. You should now see our project with beautiful, Lightbox2 effect image gallery with smooth display effect, navigation arrows, and image descriptions
18.118.140.204