Giter Site home page Giter Site logo

imagesloaded's Introduction

imagesLoaded

JavaScript is all like "You images done yet or what?"

imagesloaded.desandro.com

Detect when images have been loaded.

Install

Download

CDN

<script src="https://unpkg.com/imagesloaded@5/imagesloaded.pkgd.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/imagesloaded@5/imagesloaded.pkgd.js"></script>

Package managers

Install via npm: npm install imagesloaded

Install via Yarn: yarn add imagesloaded

jQuery

You can use imagesLoaded as a jQuery Plugin.

$('#container').imagesLoaded( function() {
  // images have loaded
});

// options
$('#container').imagesLoaded( {
  // options...
  },
  function() {
    // images have loaded
  }
);

.imagesLoaded() returns a jQuery Deferred object. This allows you to use .always(), .done(), .fail() and .progress().

$('#container').imagesLoaded()
  .always( function( instance ) {
    console.log('all images loaded');
  })
  .done( function( instance ) {
    console.log('all images successfully loaded');
  })
  .fail( function() {
    console.log('all images loaded, at least one is broken');
  })
  .progress( function( instance, image ) {
    var result = image.isLoaded ? 'loaded' : 'broken';
    console.log( 'image is ' + result + ' for ' + image.img.src );
  });

Vanilla JavaScript

You can use imagesLoaded with vanilla JS.

imagesLoaded( elem, callback )
// options
imagesLoaded( elem, options, callback )
// you can use `new` if you like
new imagesLoaded( elem, callback )
  • elem Element, NodeList, Array, or Selector String
  • options Object
  • callback Function - function triggered after all images have been loaded

Using a callback function is the same as binding it to the always event (see below).

// element
imagesLoaded( document.querySelector('#container'), function( instance ) {
  console.log('all images are loaded');
});
// selector string
imagesLoaded( '#container', function() {...});
// multiple elements
var posts = document.querySelectorAll('.post');
imagesLoaded( posts, function() {...});

Bind events with vanilla JS with .on(), .off(), and .once() methods.

var imgLoad = imagesLoaded( elem );
function onAlways( instance ) {
  console.log('all images are loaded');
}
// bind with .on()
imgLoad.on( 'always', onAlways );
// unbind with .off()
imgLoad.off( 'always', onAlways );

Background

Detect when background images have loaded, in addition to <img>s.

Set { background: true } to detect when the element's background image has loaded.

// jQuery
$('#container').imagesLoaded( { background: true }, function() {
  console.log('#container background image loaded');
});

// vanilla JS
imagesLoaded( '#container', { background: true }, function() {
  console.log('#container background image loaded');
});

See jQuery demo or vanilla JS demo on CodePen.

Set to a selector string like { background: '.item' } to detect when the background images of child elements have loaded.

// jQuery
$('#container').imagesLoaded( { background: '.item' }, function() {
  console.log('all .item background images loaded');
});

// vanilla JS
imagesLoaded( '#container', { background: '.item' }, function() {
  console.log('all .item background images loaded');
});

See jQuery demo or vanilla JS demo on CodePen.

Events

always

// jQuery
$('#container').imagesLoaded().always( function( instance ) {
  console.log('ALWAYS - all images have been loaded');
});

// vanilla JS
imgLoad.on( 'always', function( instance ) {
  console.log('ALWAYS - all images have been loaded');
});

Triggered after all images have been either loaded or confirmed broken.

  • instance imagesLoaded - the imagesLoaded instance

done

// jQuery
$('#container').imagesLoaded().done( function( instance ) {
  console.log('DONE  - all images have been successfully loaded');
});

// vanilla JS
imgLoad.on( 'done', function( instance ) {
  console.log('DONE  - all images have been successfully loaded');
});

Triggered after all images have successfully loaded without any broken images.

fail

$('#container').imagesLoaded().fail( function( instance ) {
  console.log('FAIL - all images loaded, at least one is broken');
});

// vanilla JS
imgLoad.on( 'fail', function( instance ) {
  console.log('FAIL - all images loaded, at least one is broken');
});

Triggered after all images have been loaded with at least one broken image.

progress

imgLoad.on( 'progress', function( instance, image ) {
  var result = image.isLoaded ? 'loaded' : 'broken';
  console.log( 'image is ' + result + ' for ' + image.img.src );
});

Triggered after each image has been loaded.

  • instance imagesLoaded - the imagesLoaded instance
  • image LoadingImage - the LoadingImage instance of the loaded image

Properties

LoadingImage.img

Image - The img element

LoadingImage.isLoaded

Boolean - true when the image has successfully loaded

imagesLoaded.images

Array of LoadingImage instances for each image detected

var imgLoad = imagesLoaded('#container');
imgLoad.on( 'always', function() {
  console.log( imgLoad.images.length + ' images loaded' );
  // detect which image is broken
  for ( var i = 0, len = imgLoad.images.length; i < len; i++ ) {
    var image = imgLoad.images[i];
    var result = image.isLoaded ? 'loaded' : 'broken';
    console.log( 'image is ' + result + ' for ' + image.img.src );
  }
});

Webpack

Install imagesLoaded with npm.

npm install imagesloaded

You can then require('imagesloaded').

// main.js
var imagesLoaded = require('imagesloaded');

imagesLoaded( '#container', function() {
  // images have loaded
});

Use .makeJQueryPlugin to make .imagesLoaded() jQuery plugin.

// main.js
var imagesLoaded = require('imagesloaded');
var $ = require('jquery');

// provide jQuery argument
imagesLoaded.makeJQueryPlugin( $ );
// now use .imagesLoaded() jQuery plugin
$('#container').imagesLoaded( function() {...});

Run webpack.

webpack main.js bundle.js

Browserify

imagesLoaded works with Browserify.

npm install imagesloaded --save
var imagesLoaded = require('imagesloaded');

imagesLoaded( elem, function() {...} );

Use .makeJQueryPlugin to make to use .imagesLoaded() jQuery plugin.

var $ = require('jquery');
var imagesLoaded = require('imagesloaded');

// provide jQuery argument
imagesLoaded.makeJQueryPlugin( $ );
// now use .imagesLoaded() jQuery plugin
$('#container').imagesLoaded( function() {...});

Browser support

  • Chrome 49+
  • Firefox 41+
  • Edge 14+
  • iOS Safari 8+

Use imagesLoaded v4 for Internet Explorer and other older browser support.

Development

Development uses Node.js v16 with npm v8

nvm use

MIT License

imagesLoaded is released under the MIT License. Have at it.

imagesloaded's People

Contributors

adam-h avatar alagos avatar avish avatar cpwinn avatar darsain avatar desandro avatar gscottolson avatar killua99 avatar koenpunt avatar mathiasbynens avatar moimikey avatar npmcdn-to-unpkg-bot avatar oswaldoacauan avatar paulirish avatar prayagverma avatar sdepold avatar timmywil avatar treyhunner avatar vaibhavsagar avatar yconst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagesloaded's Issues

Firefox 18 OSX and Win7 loaded-event triggered before image is loaded.

I'm not sure if I'm doing something wrong or if something is going on in Firefox on this page: http://fl.chrisjohansson.com/gallery/lega-figure/ (and it's siblings).

The summary is: I hide an image, show a loader, switch out the img src, run imagesLoaded and show the image again. This works splendidly in all tested browsers.

However, it seems firefox is triggering events before the image is loaded. So while it's doing all that it should it's not actually waiting for the image to load. It reminds me of some issue I think I read somewhere about it thinking an image is cached when it isn't. I'm just not good enough at debugging to be able to pinpoint that.

It works in all other tested browsers.

Thanks!

Bugs appending new elements (Infinite scroll + Masonry / Isotope)

Several users have had problems with past versions of imagesLoaded (pre v1.1.0) and Infinite Scroll with Masonry or Isotope. If you're having trouble as well with these, please speak up.

This issue tracker will collect the previous issues held in Masonry and Isotope.

Image is loading in Firefox 19 but "fail" is fired instead of "done"

Works perfectly in Chrome. However, in Firefox 19, the image is loading, but the "fail" callback is being fired instead of "done". Here is the code I have that I am testing (in coffeescript)

$('.image').each ->
            dfd = $(this).imagesLoaded
                done: (img) ->
                    console.log('done')
                fail: (img, proper, broken) ->
                    console.log("failed proper=#{proper.length} broken=#{broken.length}")
                always: -> console.log("fired always")

Here is the console output (I have 3 images on the page):

failed proper=0 broken=1
fired always
failed proper=0 broken=1
fired always
failed proper=0 broken=1
fired always

Target certain single img after loaded

Re #21 @lmeurs brought up the idea that there ought be some mechanism to allow the user to know when exact image has loaded

<ul id="list">
  <li><img src="alpha.jpg" /></ul>
  <li><img src="beta.jpg" /></ul>
  <li><img src="gamma.jpg" /></ul>
</ul>

So that I can use $('#list').imagesLoaded() and do something exactly when - and only when - beta.jpg loads.


Maybe the easiest solution is provide an img argument in dfd.progress

imagesLoaded combinig ASP.NET

I suggest that you change the line $images into
$images = $this.find('img').add($this.filter('img')).find('input[type="image"]').add($this.filter('input[type="image"]'))

as this add a support for images on asp:imagebutton

AMD Support

Using a shim is easy enough, but built in AMD support would be cool.

jQuery-less imagesLoaded

I'm curious to gauge the interest in a version of imagesLoaded without the jQuery dependency.

Personally, I have Vanilla Masonry and other projects in the works which could benefit from a vanilla imagesLoaded.

Chime in if you're interested as well. 🔔

IE9 + generated content in image source bug

Hey, seeing as image preloading is pretty important when working with temaplating (tumblr, shopify, wordpress etc) I thought I'd pass this along.

There's a bug in IE9 that causes this script to occasionally fail. I believe I've tracked the problem down to CDN's appended generated content onto the end of the image url.

For example if you have an image titled "logo.png", after you upload it to a particular CDN, in our case the image's url was changed to "logo.png?1293". I'm still not certain exactly why this causes a problem with the imagesLoaded script, but I believe it has to do caching.

To get around this problem I capture the images source before it hits "imagesLoaded" and split it into an array and pop off anything I don't like and then update the image attributes to have the new fixed source. For me it was everything after and including the "?". All seems to work now.

Again this is only occurring for me and a colleague in IE9. Figured it could be of some use to you, or others.

Callback definition accuracy

Documentation from project's main page could be more accurate - what I'm talking about are differences between callback function and callback objects - I guess that passing function as callback equals passing function as "always" object in callback, but it should be clarified in read-me file.

do not cache events?

If I understand correctly, you ‘cache’ events in that when the user try to load an image for the second time you trigger the event that has been saved (cached) when loading for the first time.

It is good when the image has been loaded successfully. But what if the image was loaded with errors for the first time and then the user would like to give it a try the second time?

I’m not sure for 100% but it seems to me that I have seen many times corrupted images that could be loaded the next time.

Security warning in IE7 when using https

When using the imagesLoaded plugin on a site using https I get a security warning claiming that the page contains both secure and nonsecure items. The reason seems to be that the plugin is using the data protocol (for providing a blank image) in the image src attribute and IE7 considers this to be insecure.

JSLint "Strict violation"

I know this is a minor issue and not "really" a bug, but using strict mode and running the script through JSlint I am getting a warning on the imgLoaded function...

function imgLoaded() {
if (--len <= 0 && this.src !== blank) {
setTimeout(triggerCallback);
$images.unbind('load error', imgLoaded);
}
}

... a fix is to use the $this argument you've already declared up above...

function imgLoaded() {
if (--len <= 0 && $this.attr('src') !== blank) {
setTimeout(triggerCallback);
$images.unbind('load error', imgLoaded);
}
}

You could also use $this.get(0).src, not really sure if this affects the performance at all.

Can't query image dimensions

WebKit browsers occasionally fail to report image width and height , it doesn't matter if the image is pulled from cache or not, although callback always fires.

If I modify the plugin to include a delay in "setTimeout", anything other than zero, then it works.

imagesloaded / issue

hello:

If I want turn pictures into "div" elements,what,should i do?

look forward for your replay,thx

problem activating imagesloaded in joomla with the masonry script

this is my code

addScriptDeclaration(' $(function($){alert(1); var $container = $("#container"); $container.imagesLoaded( function(){alert(2); $container.masonry({ itemSelector : ".ithem", }); }); }); '); ?>

the alert 1 runs but not the alert 2
i can make the script run in a normal setup but not with Joomla
i do not get any warnings from chrome so i have no idea what is wrong
any ideas what i do must do to make it work in Joomla

Unbinding imagesLoaded

What's the proper way to "unbind" the imagesLoaded event/callback?

Scenario: I need to unbind the imagesLoaded callback because I'm nulling the callback before the image has loaded (because the user is impatient and wants to get the next image OR just go to a new page entirely). So the image might load in the time it takes for me to transition-out of a page and remove it from the DOM... meaning it's going to run a callBack unnecessarily or even in error.

Right now I do this to bind/unbind

$("#some-photo").imagesLoaded($.proxy(this.onImagesLoaded, this)); // to bind 
$("#some-photo").unbind(); // to unbind.. which sucks for anything else bound here

I think I'd like to do

$("#some-photo").bind("load.imagesLoaded error.imagesLoaded", $.proxy(this.onImagesLoaded, this)); 
$("#some-photo").unbind("load.imagesLoaded error.imagesLoaded", $.proxy(this.onImagesLoaded, this)); 

What do you think?

Changing src attribute value at runtime does not fire progress event!

Please look at this jsfiddle sample - http://jsfiddle.net/terrorix/aHb9T/

First time when image is loaded "progress" event is fired and image is decorated with css border. Next time when you click on "Change image" link, src of that image is changed to other url but event progress is not fired.
I also try to add $.removeData($('#img1'), 'imagesLoaded'); before setting new src, but this does not help either.

I need to reuse same img element to show different images depending on user action. How can i do this?

Interaction with canvas?

I'm working on a site that is mostly being done in canvas.

I'd be keen to use imagesloaded to take care of the imageloading, before pulling them into canvas, but i'm not sure whether this is overkill?

I'm mainly after the callbacks and progress bars, as obviously, canvas elements don't interact with jQuery, so i'd take the image objects and pull them into canvas.

So basically, i'm wondering whether i can make use of this plugin or whether i should just write my own little progress loader?

callback event only fires up on deferred.always

I'm not sure if it's only on my side that is happening, but it seems like the only defer available when calling the imagesLoaded() it's .always(), the rest don't respond at all. Could it be an issue or something I'm doing wrong.

I call the function like so :

var deferred = $("ul.someClass").find("img").imagesLoaded();

deferred.done(function() { console.log("I'm done loading images"); }); /* does't log anything */
deferred.always(function() { console.log("I'm done but I might have not loaded all images yet"); });

I also have to state that the images are loaded from S3, maybe that could be an issue ?

IE compatibility

hi,
first thanks for this great plugin.

It seems to work in IE sometimes, but not always (esp in IE8 but also 9). Seems IE gets tripped by the set to blank "hack" (it is a hack for webkit AFAIU, is it not?). I added an IE check (I know not good practice but the hack seems for webkit and maybe should stay for webkit only) and only if not do the "this.src = blank;" thing. Firefox does not seem to bother either way by the way...

I had the IE problem specifically with http://tympanus.net/codrops/2011/09/05/slicebox-3d-image-slider/ which includes the imagesloaded plugin but even after update to newest was most of the times failing (the demo seems to work but on a busier page it mostly did not).

If you want I can add the complete code.

Have you run into such an issue somewhere? I tested under Windows 7 64bit IE9 and 7/8 compat mode settings.

Thanks!

Never arriving to doneLoading in IE8

I'm using imagesLoaded with isotope, calling isotope after the images are loaded. Works perfect in Firefox, Chrome, IE9. However in IE8 it is going into the imgLoaded() function for couple of my images and then it stops and never finishes.
It looks like it has problem with caching the images with $.data( img, 'imagesLoaded', { isBroken: isBroken, src: img.src } );
even though the same image should be loaded few times it is never firing console.log within the if ( cached && cached.src === src ).

IE occasionally aborts image load

We're using imagesloaded in a lazy-loading widget. A few of the initial images have hard coded src, the rest are inserted lazily from a data-src attribute. On IE9, the Network Developer tab shows the lazy images aborting on the first attemp and then immediately reloading successfully. However, the hard-coded images occasionally abort as well, and never get loaded. This happens irregularly, sometimes reloading with a clear cache 30 times before it happens again.

I can't reproduce the problem when I remove imagesloaded (the src is otherwise untouched for them).
So far, I've been unable to reproduce it on JSFiddle http://jsfiddle.net/bluescrubbie/VxFb4/12/.

I know it's obscure, but I thought I'd let you know.

More granular handling of error and success callbacks

After merging #11, imagesLoaded will trigger even if there are broken image paths. I see this as a bug, since the "images" have not all loaded, they are broken.

Per @darsain's research, figuring out if images are loaded or broken seems a bit convoluted. Perhaps fileSize = -1 together with an error event might prove to be worthwhile.

It could be beneficial to adopt jQuery Deferred Object methods .done(), .fail(), .always(), so that users have better control of how to handle loaded or broken images.

remove setTimeout

I added a setTimeout specifically for cloning/appending new elements in Chrome. It's a bit of a cheat, so we may want to remove it.

Adding the viewport meta value of user-scalable=no stops imageLoaded from firing?

I'm using imagesLoaded to help me with my layout using the dotdotdot, masonry and infinitescroll, and I have it working just fine in all browsers I was testing it in, however, when it came to making sure that the site could handle an orientation change, I added the following meta tags to have iPhone safari scale back down http://stackoverflow.com/questions/2581957/iphone-safari-does-not-auto-scale-back-down-on-portrait-landscape-portrait.

However, once I did this imageLoaded just stopped firing. I'm not looking for a solution, because I'm probably going to find another solution to detect an orientation change so that users can still zoom etc., just wanted to know if this behavior is known, expected, explainable?

imagesLoaded does not fire in Android 2.2

That just about says it. I have this pluggin functioning properly in ie7-9, FF3.6-14, Chrome, Safari, Opera, Android 2.3-4.1, iOS4-5, and Windows Phone. But for whatever reason, it just does not fire with android 2.2. Sorry I can't be more helpful, no errors, nothing, it just does not fire.

imagesloaded() sometimes called too soon + lack of check if image is loaded

Hi there,

Great script, but ran into 2 problems when changing the source of an image to load another. I might have a solution that I successfully tested on Chrome15, FF10, IE9 and IE8 (XP).

At http://www.wishdesign.nl/fora/imagesloaded/problem.htm you see the demo. In FF10 & IE8/9: when you click the image and imageloaded() is called, the image URL is changed, but the width remained the width of the previous image. Keep clicking, it keeps occurring.

A workaround seems to be to clone the image element and replace the original image with this clone. See http://www.wishdesign.nl/fora/imagesloaded/fix1.htm.

Now the right widths are shown, but not always for uncached images. So I built in a function that checks whether the image is actually loaded. Now everything seems fine, see http://www.wishdesign.nl/fora/imagesloaded/fix2.htm.

These demo's are based on a single image and my solution is not implemented in imageloaded() yet, so see it as a proof of concept?

Cheers,

Laurens Meurs

More extensive demos & tests

Right now the demo/test exhibits two tests cases: on doc ready, and cloning/appending elements. Are there any other test cases we should consider?

  • Using other images
  • pulling images from Flickr/imgur/instagram API
  • Infinite Scroll
  • Tumblr pages

Possibility to catch number of items loaded?

Hello,

I'm trying to set something like: if 15 images are loaded, do this, else do that. If all images are loaded, hide a certain div.

$('#photographs').imagesLoaded(function($images) {
var totalAmount = $images.length;
if(($images.length) > 15) {
$("#photographs, #loader").fadeIn("fast");
$("#bigloader").fadeOut("fast");
$("#photographs").gridalicious({
gutter: 2,
animate: true,
effect: 'fadeInOnAppear',
width: 430,
complete: onComplete()
});
} else if(($images.length) == totalAmount) {
$("#loader").fadeOut("fast");
};
});

This is does not seem to have any effect. Is this a bug or just a fault of my own?

Possible IE9 issue - imagesLoaded not firing events in certain cases

Example:
http://jsfiddle.net/3xmut/

What this script does:
Sequential pre-loading of a list of images.

Expected behavior:
The script loads and caches the three images in the list, and when completed, displays 100% in the HTML <div /> element.
There's no problem in Chrome or Firefox.
The point of this script is to guarantee images used in CSS background-image URLs are cached when needed.

Issue:

  • This issue does not occur if the IE9 "F12 Developer's Tools" console is open before the script runs. *
    In IE9, with no dev console open, this script stays at 0%.
    The load or fail event is not called for the first image in the list, so nothing happens.

Notes:
If I place an alert() in the preloadImage method, it fixes the issue in IE9, much like having the dev console open before the script loads.

I may be using imagesLoaded incorrectly, but it does do what I want it to do in Chrome and Firefox.

Deferred progress method not firing for all images

I was previously using Deferred.done to fade in all images once they had loaded:

// Call imagesLoaded with callback and save the deferred object
var dfd = $("#content-container .loading").imagesLoaded();

 Deferred magic
    dfd.done(function ($images) {
        $images.fadeIn(300);
    });

After upgrading to 1.7.1 I wanted to fade in each image individually once it has loaded:

dfd.progress(function (isBroken, $images, $proper, $broken) {
    if (isBroken) {
        this.parent().removeClass("loading").addClass("broken");
    } else {
        this.fadeIn(300).parent().removeClass("loading");
    }
})

However, this rarely works for every image on the page. More often than not there are a few images that fail to load. I'm assuming that the progress callback is not firing as they still have the class "loading".

Thanks.

data-src attribute

Hi, hoping someone can help...

I'm using this alongside foresight.js which uses the data-src attribute. This seems to stop imagesLoaded from working.

This is the type of markup, and output, for foresight.js:

<img data-src="img/small.jpg" data-width="480" data-height="300" class="fs-img fs-standard-resolution fs-src-find-replace" style="display: inline;" src="img/large.jpg">

If I remove the data-src from the markup and just leave a regular src, everything works with imagesLoaded as expected.

Any idea how I can overcome this?

typeof test on callback

When using the plugin in the following method;

var dfd = $('#my-container').imagesLoaded();

There is an error on line 49 when no "callback" is supplied.

May I recommend modifying the code to the following

if ( typeof callback === 'function' ) {
callback.call( $this, $images, $proper, $broken );
}

wrong ajp

the "ajp" who commented on jquery-dev-google group that you have linked was not me :) so that mysterious gentleman is the one due the credit there.

Opera 12.02 + broken images = ImagesLoaded fail

I've tracked the issue with Opera 12.02 down to broken images + scripts at the top of the page.
While I can get .fail() / isBroken working with other browsers when using the script at the top, Opera just... ignores them.

It works like if the broken images didn't exist, so, it reports that nothing is broken and everything loaded fine, but when the time to execute the code after loading the images comes nothing happens.

What puzzled me is that the example here worked on Opera: http://desandro.github.com/imagesloaded/#!advanced
It drived me crazy until I tried to move the script to the bottom of the page. I guess it's related to $('img').error() working only if placed after the said image.

jsFiddles for testing Opera vs World
With script at the top of the page: http://jsfiddle.net/dF4bj/1/
With script at the bottom of the page: http://jsfiddle.net/dF4bj/2/

best practice for throttling?

Wondering how to best use this library to throttle changes to the src attribute.

I have an image which gets its src attribute changed frequently, and want to know when it has successfully completed a load (and not get confused when it gets its src attribute swapped out midway through, thereby interrupting its download). Thank you!

Reload of broken images doesn't seem to be supported

I'm making a photo collage and using an unreliable service while developing so I often have broken images. I try to remedy that by reloading the images with (using jQuery)

$('#content-scene img').imagesLoaded(function($images, $proper, $broken) {
    // reload broken images
    $broken.each(function(i, img) {
       img.src += '?reload=' + new Date().getTime();
    });
   ...

I then do some logic with the $proper images. My expectation is that the function would be called again when the $broken images are loaded but it never happens. Is this a flaw in my expectation or a bug in imagesloaded?

I don't have time to dig into this right now but will update this with a test case as soon as possible. Probably later tonight.

Cheers, Jon.

PS. Link to dev page: https://c9.io/dotnetcarpenter/mireia/workspace/newsite/collections.html (not guarantied to be working in your browser ;-s )

$.progress callback doesn't always fire in Firefox. Cache issue?

Webkit browsers seem to be handling the images loading fine, but i've noticed that unless i do a hard refresh, the $.progress callback doesn't fire for all the images, only a few.

So if i have a fade transition that reveals the images inside $.progress, a lot of the images are still hidden, even though they've loaded.

Is the only way to get round this at the moment to double check if some of the images are hidden, and if so, fade them in using the $.done callback?

Deferreds use requires jQuery > v1.7

Re: @fredhq's good point in #17, use of the jQuery Deferred requires that imagesLoaded use jQuery v1.7 or greater. Deferreds landed in v1.5.

Could we add the deferreds awesome sauce only if its supported in jQuery?

How to get and set Image Attribut Width and Height?

Hello...

I want to know how to get image width and height, so then I want to set this attribute Width and Height on ImagesLoaded called?,
I know it can be get using php, but I want to know using ImagesLoaded plugin,

thanks...

modifying for cache vs load

can this function be modified to accept two functions, one for if the image is loaded remotely, and one if it's cached?

Bugs in Firefox 3.6

In demo page here http://desandro.github.com/imagesloaded/ broken images counter does not work in Firefox 3.6, also I have bugs in FF3.6 in my current project (script assuming that image is loaded before image is actually loaded), but for now I can`t make a proper test case.

upd: I also noticed, that with original script from gist here https://gist.github.com/268257 the bugs from my project are gone in FF3.6 and 10. Still can`t reproduce a bug in a small test case.

"Strict Mode" violations are back.

You brought back the "Strict Mode" violations.

in the imgLoaded() function, you're using "this" again. Before, you had changed these to "event.target", but I think you're already declaring "$this" up above, so you should be safe using that. Either way, just wanted to let you know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.