Skip to content

Instantly share code, notes, and snippets.

@mudassaralichouhan
Created November 2, 2022 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mudassaralichouhan/ff85ced733820aad73eb3197d1129e30 to your computer and use it in GitHub Desktop.
Save mudassaralichouhan/ff85ced733820aad73eb3197d1129e30 to your computer and use it in GitHub Desktop.
Detecting an image 404 in Javascript
<img src="{{ $vendor->image }}" onerror="ImgError(this)">
<script type="text/javascript">
function ImgError(source){
source.src = 'http://bbb.test/assets/images/placeholder.png';
source.onerror = "";
return true;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment