0

Is there a way to make the thumbnail images different from the fullsize images on a gallery using SlideJS plugin?

OUR SOLUTION:

We also didn't found anything on the documentation and solved it the following way:

  1. Create a custom attribute on the HTML of the thumbnails gallery:

    <div id="thumbnails">
        <img src="/path/to/thumbnail.jpg" fullsize="/path/to/fullsize.jpg" />
        <img src="/path/to/thumbnail.jpg" fullsize="/path/to/fullsize.jpg" />
        <img src="/path/to/thumbnail.jpg" fullsize="/path/to/fullsize.jpg" />
        [...]
    </div>
    
    <div id="slideshow"></div>
    
  2. When some thumbnail gets clicked, make a copy of the thumbnails div HTML, switch the attribute values and set the slideshow:

    $('#thumbnails img').click(function() {
    
        // Get a copy of element instance of thumbnails div
        var thumbnails = $(this).parent();
    
        // On that copy, switch "img" attribute with "fullsize" attribute of each image
        // and remove "fullsize" attribute for cleanliness
        thumbnails.children('img').each(function() {
    
            $(this).children().first().attr('src', $(this).children().first().attr('fullsize'));
            $(this).children().first().removeAttr('fullsize');
    
        });
    
        // Set the switched HTML to the div that will hold the slideshow
        $('#slideshow').html(thumbnails.html());
    
        // Set the slideshow
        $('#slideshow').slides({
            start: 1,
            preload: true,
            generateNextPrev: true,
            generatePagination: false,
            effect: 'fade'
        });
    
    });
    
4

0 回答 0