css placeholder for image if immage is missing 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: HIDE BROKEN IMAGES

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

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