Changing the preview when clicking thumbnails
Viewers: in countries Watching now:
Download a copy of the finished web site here.
- Preparing gallery photos using Adobe Bridge
- Adding and linking thumbnail images
- Creating the layout in HTML and CSS
- Downloading and adding jQuery to the project
- Creating preview images from anchor links
- Implementing the preload functionality
- Building a customized lightbox with the Fancybox plug-in
- Styling the zoom and contact links
Changing the preview when clicking thumbnails
So, whichever anchor link we actually clicked on, we are going to pull into a new variable called photo_caption the title attribute of that object. That's going to give us our caption. var photo_fullsize. It's going to be equal Dollar sign this .attr, and in here we are going to put href, the actual link destination of full size, because we took the thumbnail images and actually linked them to the high-resolution full-size image.
That's where that variable is going to set up. Then lastly, photo_preview. Now, photo_preview would never use the term preview.jpg. So right now in our HTML, there is no way for the browser to know we specifically will have another file size here called preview. So, what we are going to do is concatenate this by string replacing the file name fullsize with the file name preview. So, in order to do that, we are going to grab photo_fullsize, copy this, so photo_preview is going to equal photo_ fullsize.replace, beginning and ending parentheses, semicolon.
That's going to give us the URL to the preview image. Now, on the next line, we are going to actually write the HTML into the page. Dollar sign, tick mark, gallery_preview.html, beginning and ending parentheses, semicolon. Inside of the HTML tag, we are going to put two tick marks for string literal, and we are actually going to write the anchor tag we are going to create.
So, beginning tag a space href =. I am going to put to two full quote marks. I am going to end the tag and then end a tag. Inside the href, I am going to put an x for the moment. Let's add another attribute, title equals two quotes, another x, style equals background-image:url beginning and ending parentheses, semicolon, and let's put an x inside there as well.
Now in places in this string literal where we have Xs, we are going to replace these with the variables. So, let's start with photo_caption. Let's grab this and copy to the clipboard. Let's come down to title. Let's delete the x. Let's put two single tick marks, two Plus signs, and then let's paste the variable inside of there. So, what happens here is we get a concatenation of the string literal and the variables that we set. So, the first part of the statement comes right up to the two tick marks here.
Then lastly, let's come over and grab photo_preview. This is the preview JPEG url. Let's come over to the x in the image url, two ticks, two Plus signs. Then we will paste that in. Let's choose File > Save. Let's make all of our files inside of Dreamweaver are saved. Choose File > Save All. Let's come back to our operating system. Let's grab the index.html file, double-click it, Command+R or Ctrl+R to reload.
And now when I click on each of these images, I see that the image will actually update over on the right-hand side. Again, this is just an anchor link with the background style. And of course, if I roll over it, we can see the pop- up window coming in for the title. So, that works great! In the next movie, we are we are going to actually pick up the caption, and we will populate the caption to go along with the photo.
Find answers to the most frequently asked questions about Create an Interactive Photo Gallery with jQuery and Dreamweaver .
Here are the FAQs that matched your search "" :
- 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 fancybox.net. 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 http://fancybox.net/api.
- 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
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.