Created
November 2, 2022 18:13
-
-
Save mudassaralichouhan/ff85ced733820aad73eb3197d1129e30 to your computer and use it in GitHub Desktop.
Detecting an image 404 in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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