jQuery Cycle Plugin - Dictate locaton of thumbnails

后端 未结 1 1351
难免孤独
难免孤独 2021-01-24 11:27

What I would like to do is dictate where my thumbnails are instead of using the main images as the thumbnail.

I\'m pretty sure this can be done, I just need a little pus

相关标签:
1条回答
  • 2021-01-24 12:00

    If you're talking about a scenario like the one described here http://malsup.com/jquery/cycle/pager2.html, you should be able to do something like the following:

    pagerAnchorBuilder: function(id, slide) { 
        var thumb_prefix = "t_";
        return '<li><a href="#"><img src="' + thumb_prefix + slide.src + '" width="50" height="50" /></a></li>';
    }
    

    This is the simplest example, of course you can do something different depending on your naming convention and particular application, for example inserting a t at the end before the extension:

    pagerAnchorBuilder: function(id, slide) { 
    
        // Split off the filename with no extension (period + 3 letter extension)
        var new_src = slide.src.substring(0,slide.src.length-4);
    
        // Add the "t"
        new_src += "t";
    
        // Add the period and the 3 letter extension back on
        new_src += slide.src.substring(slide.src.length-4,slide.src.length);
    
        // Set this as the source for our image
        return '<li><a href="#"><img src="' + new_src + '" width="50" height="50" /></a></li>';
    }
    
    0 讨论(0)
提交回复
热议问题