I'd like to replace broken images with default one in a image gallery. I use jQuery to do this:
<img src="#{articleController.getArticleMainImageLink(index)}"
class="articleImage" alt="#{msg['no.image.data']}" />
<script type="text/javascript">
$(document).ready(function () {
$("img.articleImage").on("error", function(){
$(this).attr("src", "http://images5.fanpop.com/image/photos/28900000/Adriana-Lima-adriana-lima-28919058-1280-1024.jpg");
})
});
</script>
The problem is that the default images do not appear immediately after page reload but after about two minutes (browser timeout?) (tested with Firefox 31, Safari 6.1.6). Is there any way to resolve this problem?