cropperjs icon indicating copy to clipboard operation
cropperjs copied to clipboard

Fire error event when cropper init failed

Open 7anshuai opened this issue 4 years ago • 5 comments

Is your feature request related to a problem? Please describe. When init cropper failed, fire an error event. Ex. init cropper with a cross-origin URL and load the target image failed.

Describe the solution you'd like Add error event support. Like the ready event, but fires when the target image load failed and the cropper instance is not ready for operating.

Describe alternatives you've considered Before init cropper with an image URL, the user should check the image URL worked as expect manually.

Additional context Commits about error event

7anshuai avatar Jun 03 '20 01:06 7anshuai

I am not sure if this is really necessary now. I will think about this next.

fengyuanchen avatar Jun 07 '20 04:06 fengyuanchen

Any possibility of launching this feature? I would like the same solution, because when the url passed in the image is broken or does not exist, I would like to shoot something for the user.

MTAugusto avatar Apr 24 '21 20:04 MTAugusto

@MTAugusto For your case, you can just check if the image URL is valid (loaded successfully) before init a cropper.

fengyuanchen avatar Apr 28 '21 14:04 fengyuanchen

@MTAugusto For your case, you can just check if the image URL is valid (loaded successfully) before init a cropper.

He will consume extra traffic if the picture is bigger

thetbw avatar Jan 11 '22 08:01 thetbw

You can use onerror on your img element to handle this https://medium.com/@vipinc.007/html-do-you-know-img-tag-has-an-onerror-event-62011d45959

RobbieTheWagner avatar Feb 01 '23 16:02 RobbieTheWagner