2

I am wondering, is there a way to replace broken image with some other one in JSF when using grapicImage?

I found a solution in JavaScript:

<img src="image.png" onError="this.onerror=null;this.src='/images/noimage.gif';" />

However graphicImage doesn't support onError handling.

Community
  • 1
  • 1
Kuba Spatny
  • 26,618
  • 9
  • 40
  • 63

1 Answers1

0

It possible using a simple jQuery script:

<script type="text/javascript">
      jQuery(document).ready(function() {
      var $ = jQuery;
      var Element = ".poster";
      $(Element).error(function () {
          $(this).unbind("error").attr("src", "error.jpeg");
      });
      });
</script>
Kuba Spatny
  • 26,618
  • 9
  • 40
  • 63