Taking of advantage that your are adding this code, could you check the onerror when we load the image?

```js
img.onerror = function onError() {
  img.onerror = img.onload = null;
  callback();
} 
```