Subscribe to our feed...

http://feeds.feedburner.com/design-notes

  • Push Your Designs To Perfection

    goldSCHNITT is a small stand alone application for MAC that helps you apply golden ration to your design. Golden ratio(1.61803) is believed as a ratio of perfection. It has been used by many artists and architects through the history.

    Now we have this small app called goldSCHNITT to help you implement golden ration into your design.

How to create a Feature Article slide show with thumbnails and indicator

Under: Feature Articles, jQuery 29 comments

I 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

slideshow on Goal.com

Divs Explained

feature-gallery-tutorial

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:

  1. 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
  2. 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>
  3. 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>
  4. 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.

    Thebefore option specifies the name of the callback function to be invoked
    immediately before a slide transition. The after option 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>
  5. 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>
    ';
            }
  6. 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
    });
    });
  7. 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;}
  8. 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>
  9. (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.

ADD TOAdd To Evernote

If this helps, why not tell your friends?

  • Reddit
  • del.icio.us
  • StumbleUpon
  • Facebook
  • Technorati
  • Design Float
  • Identi.ca
  • FriendFeed
  • Yahoo! Buzz
  • Ping.fm

29 Responses to “ How to create a Feature Article slide show with thumbnails and indicator ”

  • Marc says:

    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]

  • Grant says:

    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:

    Sure just apply some CSS rules, make the position absolute etc…

    [Reply]

  • james says:

    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]

  • Brendan says:

    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:

    I have fixed it. Thanks for telling me. It got messed up when moving server

    [Reply]

  • caitlin says:

    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:

    set auto to false in javascript. Read more on jcarousel please

    [Reply]

  • a says:

    there is a some way to do scroll on hover mouse event?

    [Reply]

  • Jarod says:

    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:

    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:

    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]

  • siobahn says:

    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:

    Hi
    there are many great sites explains CSS well. You can try wc3school. Good luck

    [Reply]

  • Mike says:

    When you click on an image in the pager it is highlighted in pink. How do I change that color?

    [Reply]

    alexandra Reply:

    hi
    the color can be changed by modifying the css code at the top of the page

    [Reply]

  • Mike says:

    How do I hide the entire pager with jquery?

    I tried $(‘#feature_gallery_pager’).toggle();

    but the previous/next arrows are still visible.

    [Reply]

  • fazil says:

    Iam newbiee can u please tell me where u have store the images

    [Reply]

    alexandra Reply:

    I linked images from http://www.flickr.com/

    [Reply]

  • jeremie says:

    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]

  • nits says:

    great styff for the bloggers thanks
    nits´s last blog ..How to increase Google Page Rank-Make create Quality Backlinks

    [Reply]

  • Brand Green says:

    Nice information. Thanks a lot
    Brand Green´s last blog ..Hello world!

    [Reply]

  • Foodie says:

    nice piece of info. Thanks buddy
    Foodie´s last blog ..Fish Curry

    [Reply]

  • kenny says:

    Thanks a lot on your tutorial. I would like to know how can I use it on ASP.NET

    [Reply]

  • suzt808 says:

    Great tutorial thank you for sharing.
    I adapted your approach in wordpress to pull the post-thumbnail which is now part of Wordpress

    [Reply]

  • bogs says:

    Hey man, nice tutorial…
    got 1 problem though? how do i get the pager(thumbnail) appear below the bigimg. i managed to removed the output and i want to show the thumbnail below. thanks

    [Reply]

  • ali says:

    This is really a nice slideshow. i am using it on a joomla website. it works fantastic with firefox and internet explorer but when i see it with chrome or safari it doesn’t show up. only the big picture comes. no small pictures or its id text below the big image. when i saw the error it was like

    Uncaught TypeError: Object # has no method ‘createDocumentFragment’ in js/jquery-1.3.2.js:516

    can some one tell me what is the issue with chrome and safari

    [Reply]

  • is this work with wordpress??

    [Reply]

  • Leave a Reply

    All fields marked with "*" are required.








    cakma blog anal sikis porno izle porno izle yusuf yusufs r10 Güncel Blog irc forum irc u>