How to create a Feature Article slide show with thumbnails and indicator
Under: Feature Articles, jQuery 24 commentsI am a regular visitor of tutorial 9 among other popular design sites. I really love their gallery on the front page so I tried to figure out how they did it or How I can do it maybe in some other ways. I also like watch football (soccer to Americans) so Goal.com is my favorite site too. They also got a news slide show on front page even with better features than tutorial9’s. You can also check out previous post about currently available slide show/gallery scripts .

slideshow on Goal.com
Divs Explained

Here is how I do the slide show similar to theirs.Two jQury plugins are needed: jCarousel and jQuery cycle
First of all, the features I want to have:
- Not to manually resize thumbnails
- Be able to display photos with different size and ratio
- Auto scroll with thumbnail indication
- Manually scroll though thumbnails
- Sliding effect with easing animation instead of fading
Here is the Demo
You can also download it
This is how I did it:
- Header:
<script src="js/jquery-1.3.2.js" type="text/javascript"></script> <script src="js/jquery.jcarousel.pack.js" type="text/javascript"></script> <script src="js/cycle.js" type="text/javascript"></script> <script src="js/gallery.js" type="text/javascript"></script> //your future js file
- Slide show with jQuery cycle. According to JQuery cycle’s intermedia level 2 tutorial, having a slide show with pager and auto scroll is easy. Here is the HTML code:
- Use DIV to hold your images.
- Give your gallery a name- featured gallery.
- Give images class ‘change’ for resizing with CSS
1 2 3 4 5 6 7 8 9 10 11 12
<div id=”feature_gallery”> <div class=”bigimg” title=”http://farm2.static.flickr.com/1429/1252247669_5f014e7dc1_b.jpg” id=”piknown printer took a galley of 1?> <img src=”http://farm2.static.flickr.com/1429/1252247669_5f014e7dc1_b.jpg” class=”change” ></div> <div class=”bigimg” title=”http://farm1.static.flickr.com/153/332584527_bd5efc0197_o.jpg” id=”picLorem Ipstext of tnpsum hadu typa type spec”> <img src=”http://farm1.static.flickr.com/153/332584527_bd5efc0197_o.jpg” class=”change” ></div> <div class=”bigimg” title=”http://farm4.static.flickr.com/3031/2744217176_33eeeef93a_b.jpg” id=”pum is simply dummy 3?> <img src=”http://farm4.static.flickr.com/3031/2744217176_33eeeef93a_b.jpg” class=”change” ></div> <div class=”bigimg” title=”http://farm4.static.flickr.com/3270/2694066431_009890dc49_o.jpg” id=”picg and typesetting industry. Lorem I 41?> <img src=”http://farm4.static.flickr.com/3270/2694066431_009890dc49_o.jpg” class=”change”></div> <div class=”bigimg” title=”http://farm3.static.flickr.com/2053/2163474742_76d766fcfe_o.jpg” id=”ps been the industry’s standard 5?> <img src=”http://farm3.static.flickr.com/2053/2163474742_76d766fcfe_o.jpg” class=”change”></div> <div class=”bigimg” title=”http://farm1.static.flickr.com/11/16167000_61729d3678_o.jpg” id=”picmmy text ever since the 1500s, when an un 6?> <img src=”http://farm1.static.flickr.com/11/16167000_61729d3678_o.jpg” class=”change”></div> <div class=”bigimg” title=”http://farm4.static.flickr.com/3616/3429252806_7780e14125_o.jpg” id=”pihe printinpsum he and scrambled it to make ae 1?> <img src=”http://farm4.static.flickr.com/3616/3429252806_7780e14125_o.jpg” class=”change”></div> <div class=”bigimg” title=”http://farm4.static.flickr.com/3337/3426057461_a4c7503e6f_o.jpg” id=”pihe printi1?> <img src=”http://farm4.static.flickr.com/3337/3426057461_a4c7503e6f_o.jpg” class=”change”></div> <div class=”bigimg” title=”http://farm3.static.flickr.com/2062/2083550640_7545962dc7_o.jpg” id=”picture last one”> <img src=”http://farm3.static.flickr.com/2062/2083550640_7545962dc7_o.jpg” class=”change”></div> <div id=”output”></div> </div>
- The JavaScript for jQuery Cycle:
- Wrapall bigimgs.
- Prepend ul named feature_gallery_pager before all bigimgs.
- Define scroll effect and time
$('#feature_gallery .bigimg').wrapAll(' <div class="bigimgs">').parents('#feature_gallery').prepend(' <ul id="feature_gallery_pager" class="menu">').cycle({ fx:'scrollLeft', easing: 'swing', inDelay: 250, drop: 40, timeout: 5000, pause: true, slideExpr: '.bigimg', //slide name pager: '#feature_gallery_pager'//pager name } });</ul> </div>
- I also want to have the caption or related text displayed. Then we need a call back function. There are two choices. You can use onBefore or onAfter. There isn’t too much difference.
The
beforeoption specifies the name of the callback function to be invoked
immediately before a slide transition. Theafteroption specifies the name
of the callback method to be invoked at the end of a slide transition.I will just use before.Also I stored captions or related texts in id attribute. You can always use somthing else.
$('#feature_gallery .bigimg').wrapAll(' <div class="bigimgs">').parents('#feature_gallery').prepend(' <ul id="feature_gallery_pager" class="menu">').cycle({ fx:'scrollLeft', easing: 'swing', inDelay: 250, drop: 40, timeout: 5000, pause: true, before: onBefore,//add call back function slideExpr: '.bigimg', pager: '#feature_gallery_pager' } }); function onBefore() { $('#output').html("Scrolling image:" + this.id); }</ul> </div>
- Now we need to get thumbnails from bigimgs’ url and shrink them. Add this code after pager name and define width and height for class thumbnail. What it does is to get src from bigimg’s title attribute. Now you understand why I put the image url in title attribute of its div, you can always use other attributes. Why not get it from src? cause it does not work, and I have seen many people stuck here. One guy in a forum used a whole page of code to get thumnail url. I think I just gonna take the shorcut.
pagerAnchorBuilder: function(idx, slide) { return ' <li><a href="#"><img class="thumb" src="'+slide.title+'" alt="" /></a></li> '; }
- Put thumb nails in jCarousel, so we can scroll them.The thumbnails are called feature_gallery_pager in jQuery cycle.
$(function() { jQuery('#feature_gallery_pager').jcarousel({ scroll:1 }); });
- Style with CSS:
- Define bigimg change class with width or height so they are not constrained.
- class .jcarousel-item ’s width need to be slightly smaller than it really is.
- the active slide is called a.activeSlide
body { font:12px; } a img { border:none; } .jcarousel-container { position: relative; clear:both; width:510px; margin:10px auto 0 auto; padding:0 40px; } .jcarousel-clip { z-index: 2; padding: 0; margin: 0; overflow: hidden; position: relative; } .jcarousel-list { z-index: 1; overflow: hidden; position: relative; top: 0; left: 0; margin: 0; padding: 0; } .jcarousel-item { float: left; list-style: none; /* We set the width/height explicitly. No width/height causes infinite loops. */ width:80px; }/** * Horizontal Buttons */ .jcarousel-next-horizontal { position:absolute; top:10px; right:5px; width: 32px; height: 32px; cursor: pointer; background: transparent url(jcarousel_next.png) no-repeat 0 0; } .jcarousel-next-horizontal:hover{ background-position: -32px 0; } .jcarousel-next-horizontal:active{ background-position: -64px 0; } .jcarousel-next-disabled-horizontal, .jcarousel-next-disabled-horizontal:hover, .jcarousel-next-disabled-horizontal:active { cursor: default; background-position: -96px 0; } .jcarousel-prev-horizontal { position:absolute; top:10px; left:5px; width: 32px; height: 32px; cursor: pointer; background: transparent url(jcarousel_prev.png) no-repeat 0 0; } .jcarousel-prev-horizontal:hover { background-position: -32px 0; } .jcarousel-prev-horizontal:active { background-position: -64px 0; } .jcarousel-prev-disabled-horizontal, .jcarousel-prev-disabled-horizontal:hover, .jcarousel-prev-disabled-horizontal:active { cursor: default; background-position: -96px 0; } #feature_gallery{ height:500px; width:600px; margin:auto; display:block; background-color: #F2F2F2; padding: 10px; border: 1px solid #DADADA; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; } ul#feature_gallery_pager{ display:block; margin:auto; overflow:hidden; height:65px; } #feature_gallery ul.menu li a:hover{//you can define sth here } ul#feature_gallery_pager li a{ overflow:hidden; width:80px; height:60px; padding:2px; float:left; display:block; } ul#feature_gallery_pager li{ margin:0 2px; padding:0 0 10px 0; } #feature_gallery ul.menu a.activeSlide{ background:url(arrow.png) no-repeat; } #feature_gallery .bigimgs{ overflow:hidden; background-color:#000; height:330px; width:500px; border:2px solid #fff; position:relative; margin:0 auto; } #feature_gallery img.change{ width:500px; position:relative; } #feature_gallery img.thumb{ width:80px; height:51px; } #output{ width:500px; margin:1em auto; display:block; clear:both;}
- Make the js external:
// DOM Loaded $(function(){ //init js styles $('body').addClass('hasJS'); // homepage cycles $('#feature_gallery .bigimg').wrapAll(' <div class="bigimgs">').parents('#feature_gallery').prepend(' <ul id="feature_gallery_pager" class="menu">').cycle({ fx:'scrollLeft', easing: 'swing', inDelay: 250, drop: 40, timeout: 5000, pause: true, before: onBefore, slideExpr: '.bigimg', pager: '#feature_gallery_pager', pagerAnchorBuilder: function(idx, slide) { return ' <li><a href="#"><img class="thumb" src="'+slide.title+'" alt="" /></a></li> '; } }); $(function() { jQuery('#feature_gallery_pager').jcarousel({ scroll:1 }); }); function onBefore() { $('#output').html("Scrolling image: " + this.id); } });</ul> </div>
- (optional) If your photos’ size are very different you can define the image change class like this
.change{width:600px;//make it bigger than your frame so you can move it position: relative; top:-30px;left-40px}
Next, I will show you how to integrate it with WordPress.




Hey,
I’ve been struggling to get these 2 plugins to work together all day. Had finally given up and found a link to this in some random place?!? BRILLIANT!
It helped me so much!
Thank you ;)
[Reply]
I love this tutorial, thanks so much for posting it.
Quick question, is and possible and how do I make the tumbnails go on the bottom instead of the top?
[Reply]
alexandra Reply:
June 27th, 2009 at 8:41 am
Sure just apply some CSS rules, make the position absolute etc…
[Reply]
Gonna try this codes. Whew, hope someone makes a ready-to-use plugin out of this one though. It’s kinda too techie to be inserting and tweaking codes like these into my existing wordpress blog. I’m also kinda scared I might mess things up.
james´s last blog ..Book Review: How to be Happy and Have Fun Changing the World
[Reply]
Hi the links for the demo and source code are broken.
I would like to download this example- is it still available?
[Reply]
alexandra Reply:
August 8th, 2009 at 4:28 am
I have fixed it. Thanks for telling me. It got messed up when moving server
[Reply]
can someone please tell me how to stop the auto scrolling to the next image? i’ve tried both continuous: false, and auto: false, but doesn’t seem to stop it?
Please help :)
Thank you
Caitlin
caitlin´s last blog ..rebate #1
[Reply]
alexandra Reply:
September 1st, 2009 at 7:06 pm
set auto to false in javascript. Read more on jcarousel please
[Reply]
there is a some way to do scroll on hover mouse event?
[Reply]
Great tutorial! Unfortunately, the carousel portion of the demo doesn’t render correctly in IE6. Is there a fix/workaround for it?
Thanks for the resource!
Jarod´s last blog ..Site From Scratch: Localmost (Part 1, Design)
[Reply]
alexandra Reply:
October 7th, 2009 at 8:20 pm
Hi
Im not an expert on ie 6 , in most cases I dont need to consider it. There might be some css fixes for ie6.
[Reply]
Arip Reply:
February 2nd, 2010 at 2:02 pm
You must set the width of “.jcarousel-clip” same as width of “.jcarousel-container” and change “display” in “ul#feature_gallery_pager li” to “inline”.
[Reply]
Hi there This is a great script but I am a little CSS deficient and was wondering if you could throw me a clue… To get the thumbnails on the bottom, I have tried just about everything in terms of absolute positioning, but they just have now disappeared :( … Could you possibly enlighten me on the structure of the CSS classes a bit so I could get a handle on what to change??? Thanks so much!
siobahn´s last blog ..Threadless Tshirt Giveaway at jaypeeonline.net
[Reply]
alexandra Reply:
October 13th, 2009 at 5:50 pm
Hi
there are many great sites explains CSS well. You can try wc3school. Good luck
[Reply]
When you click on an image in the pager it is highlighted in pink. How do I change that color?
[Reply]
alexandra Reply:
October 22nd, 2009 at 6:10 pm
hi
the color can be changed by modifying the css code at the top of the page
[Reply]
How do I hide the entire pager with jquery?
I tried $(‘#feature_gallery_pager’).toggle();
but the previous/next arrows are still visible.
[Reply]
Iam newbiee can u please tell me where u have store the images
[Reply]
alexandra Reply:
October 29th, 2009 at 5:56 pm
I linked images from http://www.flickr.com/
[Reply]
This is great! Quick question. I noticed that your pager does scroll automatically when it goes to the seventh thumb. I’m hoping that once it goes from the boat to the yellow triangle, the pager scrolls automatically. Thanks!
[Reply]
great styff for the bloggers thanks
nits´s last blog ..How to increase Google Page Rank-Make create Quality Backlinks
[Reply]
Nice information. Thanks a lot
Brand Green´s last blog ..Hello world!
[Reply]
nice piece of info. Thanks buddy
Foodie´s last blog ..Fish Curry
[Reply]