(function($){ // get the images of the gallery and replace it by a canvas of the same size to fix the problem with overlapping images on load. $('img[width][height]:not(.uk-overlay-panel)', $('#wk-grid281')).each(function() { var $img = $(this); if (this.width == 'auto' || this.height == 'auto' || !$img.is(':visible')) { return; } var $canvas = $('').attr({width:$img.attr('width'), height:$img.attr('height')}), img = new Image, release = function() { $canvas.remove(); $img.css('display', ''); release = function(){}; }; $img.css('display', 'none').after($canvas); $(img).on('load', function(){ release(); }); setTimeout(function(){ release(); }, 1000); img.src = this.src; }); })(jQuery);