How to set fallback image on source image not found

fallback image
fallback image

Simple snippet for image fallback for normal img tag and for angular image fallback.

Set fallback image for 404 image using onerror handler.

Image fallback for normal img

<img src="http://example.com/notfound.png" onerror="this.src='http://example.com/default.png'">
<img src="http://example.com/notfound.png" onerror="this.src='img/default.png'">

angular image fallback

<img ng-src="{{data.url}}" onerror="this.src='img/default.png'">