chrome remove broken image icon code example

Example 1: css hide image if not found

<!-- hide image if not find -->
<img src="image.png" onerror="this.style.display='none'"/>

<!-- show image after load -->
<img src="image.png" style="display: none" onload="this.style.display=''">

Example 2: no cache html

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

Example 3: HIDE BROKEN IMAGES

$('img').on('error', function(){
      $(this).hide();
  });

  /*// OR replace
  ---------------------------*/
  $('img').on('error', function (){
      $(this).attr('src', '/path/to/image/default.png');
  });

Tags:

Misc Example