Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Dreamweaver Interactive Photo Galleries with jQuery

Creating a custom function for lightbox properties provides you with in-depth training on Developer.… Show More

Create an Interactive Photo Gallery with jQuery and Dreamweaver

with Chris Converse

Video: Dreamweaver Interactive Photo Galleries with jQuery

Creating a custom function for lightbox properties provides you with in-depth training on Developer. Taught by Chris Converse as part of the Create an Interactive Photo Gallery with jQuery and Dreamweaver
Expand all | Collapse all
  1. 7m 51s
    1. Previewing the project across browsers and devices
      5m 32s
    2. About the exercise files
      2m 19s
  2. 9m 49s
    1. Renaming a series of files in Adobe Bridge
      3m 7s
    2. Using GREP for more intricate file renaming
      6m 42s
  3. 29m 5s
    1. Creating and linking HTML and CSS files
      1m 32s
    2. Save For Web & Devices in Photoshop
      7m 2s
    3. Creating empty CSS rules
      3m 55s
    4. Create, nest, and class DIV tags
      6m 0s
    5. Adding CSS properties for main container
      4m 28s
    6. Adding CSS properties for content area
      4m 0s
    7. Adding CSS properties for headings
      2m 8s
  4. 15m 55s
    1. Adding and linking the thumbnail images
      2m 32s
    2. Styling the thumbnail links with CSS
      5m 15s
    3. Downloading and adding jQuery to your project
      2m 42s
    4. Overriding the browser's default link behavior
      5m 26s
  5. 11m 10s
    1. Creating preview images from anchor links
      1m 52s
    2. Changing the preview when clicking thumbnails
      5m 59s
    3. Changing the caption when clicking thumbnails
      3m 19s
  6. 12m 0s
    1. Adding an image preload plug-in for jQuery
      2m 22s
    2. Setting a dissolve transition between previews
      4m 31s
    3. Implementing the preload functionality
      5m 7s
  7. 15m 20s
    1. Adding a lightbox plug-in for jQuery
      2m 2s
    2. Creating a custom function for lightbox properties
      7m 38s
    3. Setting links to activate the lightbox feature
      5m 40s
  8. 3m 40s
    1. Initializing the gallery on page load
      3m 40s
  9. 5m 11s
    1. Adding icons and styles to the zoom and contact links
      5m 11s
  10. 2m 40s
    1. Activating a gallery automatically in IE9 and IE10
      2m 40s
  11. 2m 43s
    1. Some ideas for further enhancements
      2m 43s

please wait ...
Creating a custom function for lightbox properties
Video duration: 7m 38s 1h 55m Intermediate


Creating a custom function for lightbox properties provides you with in-depth training on Developer. Taught by Chris Converse as part of the Create an Interactive Photo Gallery with jQuery and Dreamweaver

Creating a custom function for lightbox properties

Now, the way Fancybox works to initiate links into the lightbox is to simply add classes on anchor tags and then set up a jQuery statement that looks for those anchor tags with specific classes. If I go into the includes directory, into Fancybox, they've included an index.html file. If I double-click this, this will give me a bunch of different examples on different ways the Lightbox can work. This one here just simply fades up and down. This one here runs an elastic animation up and down, giving us that zoom effect.

This one just sort of pops on and pops off. We can also do different things with the captions. We can have captions show up underneath. We can have captions show up inside the border. And the one I like, the last one here, I can actually have the text show up inside a semi-transparent overlay. And in order to see how all of these are coded, we can take that index file and open it up in either a text editor or Dreamweaver. So at the very top here, I can see here are the different examples, and lower in the code, we can see how they are executed.

So this is an anchor tag with an ID of example 1. So example 1 is the one that just simply fades up and fades down. I'll come up to the top of the document. I'll look for example 1, which is right here, and that's just the simple Fancybox statement. Other ones here have a bunch of different settings: overlay, transitionIn, transitionOut, opacity settings, positioning for the captions, a whole bunch of different formats--and of course, the web site documents all of these different switches. So what we're going to do is go into our JavaScript file, and one of the things that we'll also need to do is typically we assign the anchor tags to be paid attention to by Fancybox by putting it in the document ready.

However, since we are going to be pulling HTML from one spot and concatenating the data into the caption area, we need to be able to reinitiate all of the links. So what we're going to do is create a brand-new function outside of the document ready in our JavaScript file and run the Update Overlay links any time we're going to make a change. So we're going to start by coming to the bottom of the document here outside of the document ready, and we're going to create our own custom function. I am going to type 'function', and we're going to call this setFancyboxLinks.

That's the name of the function. We can name this anything we want. Beginning and ending parentheses, beginning and ending bracket. I am going to hit a few returns. Now inside of here, I am going to tab in. We're going to make a jQuery statement, Dollar sign, beginning and ending parentheses, two tick marks for string literal, a.overlayLink, come outside of here, .fancybox, beginning and ending parentheses, then a semicolon.

Then inside this function, we're simply going to put just two brackets-- beginning and ending. We're going to split that open. Let's come inside here, and let's set some of the parameters. I am going to do two tick marks for a string literal. We're going to do titlePosition, space, colon, another string literal, the word over, this will place the text over top of the overlay. Let's tab in. This is going to be 'overlayColor', colon, string literal, '#000'--that's black.

Next line, string literal 'overlayOpacity' : 0.8, 80%, put a comma. Next line, type 'transitionOut', string literal, 'elastic', comma. Next line, 'transitionIn'. I just realized I spelled the first transition incorrectly.

'transitionIn', also 'elastic', then a comma. The last line we're going to turn 'autoScale': to true. Now in the last one, we don't need a comma because these are paired values, but the very last one doesn't need a comma because there's nothing that's going to be repeating after that. So now this function, setFancyboxLinks, is going to run.

It's going to find every anchor tag with the overlay link class assigned to it, and it's going to activate it as a Fancybox link. So now we need to actually initiate this function. So let's copy this. Let's scroll up. Let's come up here into the area where we are preloading the image and then setting all of the content inside both the preview and the caption. So let's come in here after we say gallery_preview.fadeIn, gallery_caption.fadeIn. Let's add another line. Then we're simply going to put setFancyboxLinks with the beginning and ending parentheses and a semicolon.

This is going to call this function. Now the last thing I need to do, let's come down and select overlay link. Let's copy that to the clipboard, Command+C or Ctrl+C, and we need to come up here and add this class into these two links. So this first one here, gallery_preview, let's put a space inside the anchor tag, class equals, two quotes, paste in overlay link. And then down here, we have our text base link which says view larger. Let's add the same class in here, class="overlayLink".

So now these two anchor tags are going to get dynamically written in. Then we're going to fade up all the content. Then we're going to run the setFancybox function. This function is going to then go back through the document, look for every anchor tag with overlay link, and it's going to find these two that we just created, and then it's just going to activate these on click to overlay the image and it's going to link it to the full-size photo, which is the href of the original anchor tag. In addition, the caption is going to come from the title tag in the anchor tag. Let's choose File > Save.

Let's go over to our operating system, and let's open up index.html in our browser. Once it opens, we will hit Command+R or Ctrl+R to Reload, click on an image. The image fades up, caption fades in, I click on the image. This initiates the lightbox. I see the full screen image. I also see the caption down here, Caption for refraction goes here. Now in the lightbox, I can actually click anywhere; I don't have to hit just on the X. It zooms back into place. Click on another photo, come down and click on the View Larger Text.

Now, notice that the image, if we use the Elastic setting, will create the elastic zoom based on the actual link. So the text link down here, the image will be really tiny, autoscale down to the size of the text link, and then zoom up. So now that this functionality is working perfectly, in the next movie, we're going to add another custom function for the update thumbnails, and then we're going to be able to set up a function that's going to autostart the gallery. So when we first load it, it will automatically highlight the first picture, set the thumbnail, and set the caption.

Find answers to the most frequently asked questions about Create an Interactive Photo Gallery with jQuery and Dreamweaver .

Expand all | Collapse all
please wait ...
Q: The finished state of the interactive photo gallery in this course shows a clickable preview. When you click on the preview image, or on the view larger icon, a larger lightbox image appears. Chris's example has a close button and border surronding the large image, but mine doesn't. Did I miss a step?
A: The functionality you describe is part of FancyBox plug-in we use in this course. It's a custom lightbox tool, which I've included in the exercise files and also available for download at It's free and highly customizable.
By default, FancyBox adds a border to images (at least in the version of FancyBox we're using), but there are many options that can be turned on when you set up your fancybox initialization script, including the close button, which is invoked using the showCloseButton property. This is all covered in the "Creating a custom function for lightbox properties" movie.
If you want to customize your gallery further, look at the list of the customizable properties at
Q: This course was updated in April, 2013. What changed?
A: Since the release of this course, Internet Explorer 9 and 10 have been released, and sometimes these browsers do not activate interactive HTML content. To remedy this problem, the author has added a movie to Chapter 10 that will show you how to:
- Update the HTML to HTML5
- Update the version of jQuery
- Use the Google html5shiv to keep compatibility with Internet Explorer 7 & 8





Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Create an Interactive Photo Gallery with jQuery and Dreamweaver.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.