great website design

By Evan

wordpress-slideshow-tutorialIn this tutorial, we are going to install a small photo slideshow with a lightbox into the sidebar of a WordPress blog. This is a great way to add colorful images and interactivity to your site. I am going to use the Slate theme, which is available as a free download from our site. Let’s jump right in.

JavaScript files

To begin with, we are going to be using a JavaScript library called jQuery. JQuery is included in the normal installation of WordPress. In addition, we will be using a jQuery plugin called the jQuery Cycle Lite Plugin. You will need to download the min version, making sure to keep the original file name. Finally, you will need the jQuery lightBox plugin.

Upload jQuery Cycle Lite Plugin

Upload the file jquery.cycle.lite.min.js to /wp-includes/js/. . This is a good place to store any javascript files that you will be using to power features on your blog.

Configure and Upload the jQuery lightBox plugin

After unloading the zip file, upload all the .gif files in the images folder to /wp-content/themes/slate/images/. Open the file jquery.lightbox-0.5.js, in a text editor like notepad. Look for this section of code:

// Configuration related to images
			imageLoading:			'images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'images/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			'images/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:			'images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'images/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)

Change the paths to include our locations. As an example:

// Configuration related to images
			imageLoading:			'/wp-content/themes/slate/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon

Save these changes. Upload this file to /wp-includes/js/.

Our final step is to copy all the stylesheet information from the file jquery.lightbox-0.5.css and paste it onto the end of the stylesheet style.css, which you can access in the theme editor available through your WordPress dashboard. Remember to include the author’s information–it’s good form and should always be done.

Linking JavaScript files

Using the theme editor in your WordPress dashboard, open the template file header.php. Just before the </head> tag paste this code:

<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-includes/js/jquery/jquery.js"></script>

<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-includes/js/jquery.cycle.lite.min.js"></script>
<script type="text/javascript">
jQuery(function() {
    jQuery('#slideshow').cycle();
});
</script>

<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-includes/js/jquery.lightbox-0.5.js"></script>
    <script type="text/javascript">
	jQuery(function() {
		jQuery('#slideshow a').lightBox({fixedNavigation:true});
	});
    </script>

In this script we are accomplishing several things. First, we are linking our site to the three JavaScript files. Next, we are defining the container that will house our slideshow. In this instance, the container is #slideshow. Lastly, we are defining the linked images that we will be targeting with the lightbox script. Again, in this instance we are targeting linked images in the div #slideshow.

Making the image files

In order for this feature to work, you will need to create the image files that will be displayed in the slideshow and the files that will be displayed in the lightbox. In this example, the smaller slideshow images will be 200px square. The larger images can be whatever size you choose. Here is an example with just one image, one at 200px square, and the other at 320 x 427px:

s2
lb2

HTML in the sidebar

I want my slideshow to display images at the top of the sidebar, above the search field. Open sidebar.php and add the following code just below the opening tag <div id="sidebar">:

<div id="slideshow">
	     <a href="<?php bloginfo('template_url'); ?>/images/your_image1.jpg" title=""><img src="<?php bloginfo('template_url'); ?>/images/your_thumb1.jpg" width="200" height="200" border="0" alt="" /></a>
             <a href="<?php bloginfo('template_url'); ?>/images/your_image2.jpg" title=""><img src="<?php bloginfo('template_url'); ?>/images/your_thumb2.jpg" width="200" height="200" border="0"  alt="" /></a>
             <a href="<?php bloginfo('template_url'); ?>/images/your_image3.jpg" title=""><img src="<?php bloginfo('template_url'); ?>/images/your_thumb3.jpg" width="200" height="200" border="0"  alt="" /></a>
             <a href="<?php bloginfo('template_url'); ?>/images/your_image4.jpg" title=""><img src="<?php bloginfo('template_url'); ?>/images/your_thumb4.jpg" width="200" height="200" border="0"  alt="" /></a>
	  </div>

Where your_image and your_thumb are replaced with the file names that you used. If you look at the structure of this html, you see that we have created the div slideshow and filled it with linked images where the destination of the link is the larger image.

Add css to the Stylesheet

Our final step is to give specific dimensions to our div. Open style.css and add:

#slideshow {
        height:  200px;
        width:   200px;
	}

Save your styesheet changes and give your blog a visit.

As a final thought, consider making a donation to the individuals or groups that supply the jQuery plugins. A little bit from a lot of people will make a big difference in their ability to produce more great stuff. Enjoy!

Related Media

  1. Free Photoshop Texture: Graffiti No. 2
  2. The Roundup of Roundups
  3. Cool Fonts: Calligraphy Fonts & Wedding Fonts
  4. Weekly Blog Stats Review: 07.11.09-07.17.09
  5. Organize your Photoshop Brushes

Comments

  1. Jason
    10.16.09

    … I also find myself torn between the coffee shop and my dual monitor setup :)

  2. Cyndi Hall
    11.04.09

    May I suggest ABR Viewer as an alternative to loading and trying each brush in Photoshop? It’s free, and I use it regularly. You may find this a great time-saving alternative!

    http://abrviewer.sourceforge.net/

    Hope it helps!

  3. Kendall
    11.04.09

    Thanks for the referral, Cyndi! I’ll have to spend some time tonight trying it out.

  4. 4elves
    02.11.10

    I love you to pieces man!!

  5. Lia
    10.14.10

    I wished and wished for a Mac, then was given one at work.

    So I moved all my files over.

    I HATE it. I’m a designer. I have about 50 folders for 50 different projects. I name the banner psd “banner.psd” for all of them. Try and search for them all, yeah the Mac finds them but then you have to do “get info” for each one (or change some such setting and still click on each to see where the dang thing is located. On windows. I glanced at the path to the folder and voila. Yeah changing permissions on Vista is a headache but it’s far better than the constant problems I have on the Mac. Photoshop is twitchy at best, the thing crashes, although my Roku, PS3, Wii, personal laptop all do fine with my wirless, the mac drops it all the time. I use multiple monitors. Oh my god what idiot thought of leaving the application menu on one screen when the application is on another? You can only choose one little sprout because Steve Jobs knows better than you how you should work.
    can’t wait to ditch it.

    sorry tirade over.

    ps tons of free windows applications out there.

  6. Obcali
    11.26.10

    Um… how about not naming all of your files the same name? Sounds more like an organizational issue than an operating system issue, either way.

    I might recommend using an identifier and THEN _banner.psd? I assume it’d be difficult to find photos as well if every picture on a drive had its own folder and was named “photo.jpg”.

    Examples:
    Projectname_size_banner.psd
    Clientname_size_banner.psd
    etc…

  7. Russell
    04.17.11

    Ok, so… I’m a total newbie to photoshop. I have CS5 and a brickton of brushes. I have tried renaming them, but they do NOT show up in the list like I want them to. I’ve played around with it for like a half hour. Can anyone please help?

Leave a Comment