throw an error if image could not be loaded

This commit is contained in:
Martin
2017-08-05 01:27:06 +02:00
parent ad42bbfe03
commit bf55ced590
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -124,12 +124,16 @@ function ImageEditor(canvasId, args) {
*/
this.loadImage = function (url, callback) {
callback = typeof callback === 'function' ? callback : function () {};
fabric.Image.fromURL(this._url = url, function (img) {
fabric.util.loadImage(this._url = url, function (obj) {
if(obj == null) {
throw new Error('Error loading ' + url);
}
var img = new fabric.Image(obj);
_canvas.setImage(img);
img.__url = url;
img.sendToBack();
callback(img);
});
}, { crossOrigin: 'anonymous' });
return this;
};