source: tags/2.4.3/themes/default/js/thumbnails.loader.js @ 17171

Last change on this file since 17171 was 13452, checked in by patdenice, 12 years ago

Multisize
Bug fixed if $confderivative_url_style != 0
Create a pwg_ajax_thumbnails_loader function

File size: 709 bytes
Line 
1var thumbnails_queue = jQuery.manageAjax.create('queued', {
2  queue: true, 
3  cacheResponse: false,
4  maxRequests: 3,
5  preventDoubleRequests: false
6});
7
8function add_thumbnail_to_queue(img, loop) {
9  thumbnails_queue.add({
10    type: 'GET', 
11    url: img.data('src'), 
12    data: { ajaxload: 'true' },
13    dataType: 'json',
14    success: function(result) {
15      img.attr('src', result.url);
16    },
17    error: function() {
18      if (loop < 3)
19        add_thumbnail_to_queue(img, ++loop); // Retry 3 times
20    }
21  }); 
22}
23
24function pwg_ajax_thumbnails_loader() {
25  jQuery('img[data-src]').each(function() {
26    add_thumbnail_to_queue(jQuery(this), 0);
27  });
28}
29
30jQuery(document).ready(pwg_ajax_thumbnails_loader);
Note: See TracBrowser for help on using the repository browser.