Croppie: bind() promise does not resolve on a fail

Created on 19 Jan 2018  路  2Comments  路  Source: Foliotek/Croppie

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
    })

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);
};

All 2 comments

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);
};

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nueverest picture nueverest  路  8Comments

Lenndev picture Lenndev  路  4Comments

nicolacardi picture nicolacardi  路  4Comments

Terumi picture Terumi  路  3Comments

guschnwg picture guschnwg  路  4Comments