When doing croppis.bind() we get a promise that resolves after success.
When it fails (no internet connection, XSS rejection when loading image over http, ...) the promise is never resolved.
The promised should ideally resolve in a .catch() or at least in the .then(result) with result.error = "no internet connction" for example.
To reproduce :
// ensure you don't have internet access and the image is not in cache
cropObj = new Croppie(cropArea)
cropObj.bind({
url: "http://myimage.com",
})
.then(function(result){
// never called
})
.catch(function(error){
// never called
})
Hi anyone could help me on this problem. Thanks
Uncaught (in promise) Event聽{isTrusted: true, type: "error", target: null, currentTarget: null, eventPhase: 0,聽鈥
Promise.then (async)
_bind @ croppie.js:1272
Croppie @ croppie.js:1516
(anonymous) @ croppie.js:1482
each @ jquery-3.3.1.js:354
each @ jquery-3.3.1.js:189
$.fn.croppie @ croppie.js:1481
mightThrow @ jquery-3.3.1.js:3534
process @ jquery-3.3.1.js:3602
setTimeout (async)
(anonymous) @ jquery-3.3.1.js:3640
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
fire @ jquery-3.3.1.js:3406
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
ready @ jquery-3.3.1.js:3878
completed @ jquery-3.3.1.js:3888
Hey. U must provide attr url when u make bind and it can't be empty.
correct:
$croppieEl.bind({url: 'img/product.jpg'});
not correct:
$croppieEl.bind({url: ''});
if just don't want see error in console )),u can add [return true;] in img.onerror, In my file it line 204.
so will be like that:
img.onerror = function (ev) {
return true;
img.style.opacity = 1;
setTimeout(function () {
reject(ev);
}, 1);
};
Most helpful comment
Hey. U must provide attr url when u make bind and it can't be empty.
correct:
$croppieEl.bind({url: 'img/product.jpg'});
not correct:
$croppieEl.bind({url: ''});
if just don't want see error in console )),u can add [return true;] in img.onerror, In my file it line 204.
so will be like that:
img.onerror = function (ev) {
return true;
img.style.opacity = 1;
setTimeout(function () {
reject(ev);
}, 1);
};