Reputation: 906
function handleonload(url , callback)
{
var img = new Image();
img.onError = function() {
alert('Cannot load image: "'+url+'"');
};
img.crossOrigin = '';
img.onload = function() {
callback(img);
};
img.src = url;
}
handleonload(imageurl,callbackfunction);
I am using this function for multiple images ? But i am not getting a correctly map output images some of them are repeated
Upvotes: 1
Views: 425
Reputation: 3279
Try imagesLoaded
: http://imagesloaded.desandro.com/
Usage is straightforward: imagesLoaded( elem, callback );
Upvotes: 1