Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect image load failure and if fail, attempt reload until success?

I have some images loading from offsite and have no control over their availability. I've found that under heavy load they are sometimes failing to load, but on a quick refresh they'll show right up.

Is there a way to detect if images fail to load and then if so, evoke a reload on the img src until it loads? If so, could you please provide an example?

like image 825
ylluminate Avatar asked Jan 23 '12 07:01

ylluminate


1 Answers

<img onerror="dosomthing()" ...>
like image 145
Ashraf Avatar answered Sep 18 '22 17:09

Ashraf