scaleflex / react-cloudimage-responsive

Cloudimage Responsive will smartly resize, compress and accelerate images across the World in your site for all devices. The plugin supports lazy loading technique with fancy animation on image load. Any questions or issues, please report to https://github.com/scaleflex/react-cloudimage-responsive/issues
MIT License
45 stars 16 forks source link

Is there an onerror event? #17

Closed dartmoordunbar closed 4 years ago

dartmoordunbar commented 4 years ago

Is there any way to detect the image failed to load or loaded the placeholder image? I'd like to fire off a function when this happens to rebuild the image.

dzmitry-stramavus commented 4 years ago

hey @dartmoordunbar ,

yes, it's possible.

  1. You need to configure your Filerobot container to return 404 if image missing image

  2. Just add onError handler to an image image

codesandbox: https://codesandbox.io/s/react-cloudimage-responsive-example-umkmq?file=/src/index.js