Fresh Sliding Thumbnails Gallery with jQuery and PHP

In this tutorial we are going to create another full page image gallery with a nice thumbnail area that scrolls automatically when moving the mouse. The idea is to allow […]

Stay in the loop: Get your dose of frontend twice a week

Fresh news, inspo, code demos, and UI animations—zero fluff, all quality. Make your Mondays and Thursdays creative!

Feedback 142

Comments are closed.
  1. Awesome gallery! Has anyone done a fadeOut() feature? I want to use this on my new site but I’d love to have the main image fade out before loading the next one. I’ve been trying to figure out where that should happen but I keep getting the fadeout after the new image is loaded. I’ve tried calling the fadeout with loadPicture as the callback… that doesn’t seem to work. Still a bit new to jQuery… any help would be appreciated.

  2. This tutorial is awesome, the sample data works well, however i’m having some trouble after modified the xml, the thumbnails won’t display anything, I’m using PHP 5 with json support on XAMPP.

    I even tried with Shai Perednik script and the timthumb which have those auto generated xml. That also doesn’t work for me. I even editing the xml with a real xml editor, still no luck 🙁

    Anybody have any suggestion / solutions?

  3. Agreed this is a great gallery. I too would like to be able to link to specific albums.

  4. Mary, Shai and Bali, Great work indeed. I noticed that the timthumb.php creastes a cache folder in the ajax folder and generates all the thumbnails in the cache folder. Is there a way to place all the generated thumbnails in the respective folders in the thumbs folder instead? That way, it won’t call the timthumb.php again and again. Thanks.

  5. fantastic stuff and I’m trying the static demo. There still seems to be a bug when working with Chrome (12.0.742.112)
    If I load the page I get all thumbnails, if I refresh I only get a few. If I then go to the URL bar and hit return it shows all again.
    Is this the browser at fault or some weird caching going on?

  6. integrating album choice button into a jquery menu button any ideas?

    also currently using xnview program to resize my pictures so that they are not 2-4 mb. so that they will maintain aspect ratio but keep them in the 200-400kb range for faster load times. Maybe there is a way to incorporate this into a jquery plugin to do a batch resize to the desired size but keep the aspect?

  7. Will give an update. I fixed it for Chrome and Safari. I was using timthumb to dynamically create thumbnails from the larger image. Worked fine ie IE/FF but Chrome/Safari needed me to also specify the height/width of the thumb in the <img src… statement.

  8. Is there any way, to open the image in the middle of the site, I mean not in the center between left and right, but between album selector box (on the top) and thumbs selector box (on the bottom)?

  9. Hey have used ur gallery but when am inserting the images in both the folder.
    It does not show images in thumb.

  10. Great job Mary !

    Quick question… Why using XML and not a data base ?

    Cheers,

  11. Joe,
    yes, it could be possible but trying to convert to php and embed the would code in my wordpress bugs…look like it as something to do with the ajax part. will try to work on it but I am photographer … not developer…any help is welcome.

  12. hey, this is awesome. is there away to update the URL to the pictures? that way we can link to the picture from elsewhere?

  13. @ Barry

    I am in the same boat you are in where I only get first thumbnail on page refresh in chrome.

    I see you fixed it by adding both height and width to the statement.

    I was wondering if you could the code you used since I have tried defining the height in the thumbs.php in the line of code that generates the imagearray, however that does not seem to fix my problem!

  14. Alright, I got the thumbnails to work in google chrome by using Timthumb and bypassing the browser cache.

    The issue appears to be with google chrome and they way it would cache the thumbs and the way they were being called back. By editing the headers in Timthumb you can force it so that the thumbnails are not cached locally on someone’s comp.

    This is not an ideal solution since it forces the browser to fetch them every time, and if you have a lot of thumbs, could slow the site down some. If I find a better solution or if anyone has any questions on how to adjust the headers in Timthumb to make it work, let me know!

  15. Hi Codrops folks,

    as promised I started integrating you galleries with drupal 7. The second experiment is almost done. see “http://drupal7.babygeorges.com/fresh_sliding_thumbnails_gallery”

    My first experiment now as good see, “http://drupal7.babygeorges.com/ingrandmasgarden”, I will use knowledge gain from 2nd experiment to improve on it.

    Thank you again for such beautiful work!

  16. Fixing some bugs:
    1. Chrome problem (loading only 1 or 2 thumbs when switching albums) – edit jquery.gallery.js line 137 and add there: width=”75″
    2. Sorting of thumbnails is random (everytime you display the album you see different order of thumbnails) – edit jquery.gallery.js add line after line 157 (above …’json’…) with content: $tContainer.sort();

  17. Mike, is indeed a problem with Chrome.. line 137 is unclear for me.. Could you write exactly wich line must be extended? thank you in advance.

  18. Hi,

    Do you think it’s possible to add near the desc a link for download the pictures?

    Thx

  19. thanks for this!! I enjoy it very much, but when I add my images to the folders in the correct way described up here, My images look weird. and nothing appears in the bar below 🙁 no thumbs. even when clicking on the main image, nothing happens… can u tell what I’m doing wrong?
    thanks

  20. Looks great! I downloaded it and tried to take a look in browser, but it just continues to load forever. Is the download ready as is? Am I missing something?

  21. thanks for your great tutorial i am using your script to make my gallery, but i got a problem i could not able to get large image on chrome, i tested it to my local host its works fine in all
    browser but when i upload it to my real server works on IE and Firefox but it dosent display the full image on chrome. on my console box there is a error message :
    GET http://domain.com/gallery/css/icons/plus.cur 404(Not Found)
    when i click this link it display discription:
    Name path: plus.cur (/gallery/css/icons) (Note: i dont have and icons folder in my css dis)
    type: text/html
    Initiator: jquery.min.js
    how can i romover this error thanks for any sussetions thanks

  22. I need to order the images that are displayed
    Always out in random order.
    Someone could solve this problem?

  23. Hi there

    Great tutorial, I was wondering if you had a tutorial for creating this same effect but using asp.net instead of php as our solutions are based on .net and that is the languages I understand.

  24. Fantastic tutorial as usual Mary Lou… whatever happened to youtube videos being able to be shown together with the pics in the album…
    Shai Perednik did you eventually get it to work?

  25. I followed the tutorial and it correctly works on Firefox and IE. Unfortunately it doesn’t work on Chrome, the thumbs don’t appear and the loading gif keeps moving without loading any photo.

    What’s wrong?

  26. Oh and another thing:
    I’ve numbered both the photos and the thumbnails, but every time I refresh the page the order is different. It seems to me there’s no order at all (aleatory). How can I change this?

  27. Thanks for this tutorial! I have one problem: I want to add an autoplay option to this gallery with nice FadeIn and FadeOut effects. That is make pictures to change smoothly one by one.

  28. I thought something like this code would work but it doesn’t:

    function loadPhoto($thumb,cursorClass){
    current = $thumb.index()+1;
    $(‘#imageWrapper’).empty();
    // $(‘#loading’).show();
    $(”).load(function(){
    var $theImage = $(this);
    $(‘#loading’).hide();

    $(‘#imageWrapper’).stop().fadeOut(500,function(){
    var $this = $(this);

    $this.remove();
    resize($theImage);

    $(‘#imageWrapper’).append($theImage.show());
    $theImage.stop().fadeIn(800);
    });

    }).attr(‘src’,$thumb.attr(‘alt’));
    }

  29. I found an appropriated decision:
    function loadPhoto($thumb,cursorClass){
    current = $thumb.index()+1;
    $(‘#imageWrapper’).empty();
    // $(‘#loading’).show();
    $(”).load(function(){
    var $theImage = $(this);
    $(‘#loading’).hide();
    resize($theImage,0);

    if(!$(‘#imageWrapper’).find(‘img’).length){
    $(‘#imageWrapper’).append($theImage.fadeIn(1000, function(){
    $(‘#imageWrapper’).append($theImage.delay(4000).fadeOut(1000));
    }));
    $(‘#description’).html($theImage.attr(‘title’));
    }

    }).attr(‘src’,$thumb.attr(‘alt’));
    }

  30. I love this slideshow but am having problems with the large image size.
    I have added a header with a logo and the large image seems to be cut off at the bottom now. Can anyone suggest any solutions? Thanks

  31. For Chrome thumbs problem:
    open jquery.gallery.js
    and modify line 137 to:
    $(”).load(function(){

    Chrome needs to now width to display it correctly

  32. For fixing displaying thumbs in random order:

    in jquery.gallery.js after line 157 add new line:
    $tContainer.sort();

  33. If you want to sort album list in descending order (for example if you use YYYY-MM-DD as a folder names)
    then edit jquery.gallery.js
    and replace lines 207, 208 to:
    if (keyA keyB) return -1;

  34. Hi! Wonderful tutorial!
    I’ve a little problem with my downloaded files. I can watch the online demo but I can’t see my unzipped file properly. I’ve tried with firefox, chrome and IE8. Please help me.

  35. RANDOM THUMBS PROBLEM
    I added a new line after line 157 $tContainer.sort(); but still continues to do random..

  36. Hello! I can’t solve the THUMBS problem in CHROME the 137 line is: }).attr(‘src’,$thumb.attr(‘alt’)); and I can’t change that, it won’t let me.
    How do you solve this?
    Has anyone solved the maximizing problem in IE( when you click + it changes in a flash without slowing)

    I saw that the dynamic gallery has not the THUMBS problem in CHROME. Can anyone help me changing the path to the files with php ? I don’t know any php.
    Waiting for your answers! thank you very much!!!