mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-14 00:33:09 +00:00
Add image load onerror handler
Make sure, when loading from json, that a bad image path doesn't fail the desserialization Signed-off-by: kangax <kangax@gmail.com>
This commit is contained in:
parent
dc2e5210ae
commit
d56bf59137
2 changed files with 13 additions and 4 deletions
|
|
@ -352,8 +352,15 @@
|
|||
|
||||
var instance = new fabric.Image(img, object);
|
||||
callback && callback(instance);
|
||||
img = img.onload = null;
|
||||
};
|
||||
img = img.onload = img.onerror = null;
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
img.onerror = function(e) {
|
||||
fabric.log('Error loading ' + img.src);
|
||||
callback && callback(null, true);
|
||||
img = img.onload = img.onerror = null;
|
||||
};
|
||||
img.src = src;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -223,8 +223,10 @@
|
|||
}
|
||||
var klass = getKlass(o.type);
|
||||
if (klass.async) {
|
||||
klass.fromObject(o, function (o) {
|
||||
enlivenedObjects[index] = o;
|
||||
klass.fromObject(o, function (o, error) {
|
||||
if (!error) {
|
||||
enlivenedObjects[index] = o;
|
||||
}
|
||||
onLoaded();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue