简体   繁体   English

JSF-graphicImage-替换损坏的图像

[英]JSF - graphicImage - replace broken image

I am wondering, is there a way to replace broken image with some other one in JSF when using grapicImage? 我想知道,有没有办法在使用grapicImage时用JSF中的其他图像替换损坏的图像?

I found a solution in JavaScript: 我在JavaScript中找到了一个解决方案

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

However graphicImage doesn't support onError handling. 但是,graphicsImage不支持onError处理。

It possible using a simple jQuery script: 可以使用简单的jQuery脚本:

<script type="text/javascript">
      jQuery(document).ready(function() {
      var $ = jQuery;
      var Element = ".poster";
      $(Element).error(function () {
          $(this).unbind("error").attr("src", "error.jpeg");
      });
      });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM