JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<img src="https://peviews.123rf.com/images/breeze09/breeze091009/breeze09100900239/7858738-small-nice-kittens-of-the-british-breed.jpg" alt="kitty" onerror="foo()">
</div>
CSS
.container {
overflow: hidden;
width: 300px;
height: 300px;
}
img {
width: 100%;
}
JavaScript
function foo () {
console.error('foo');
}