I am displaying a bunch of images in some gallery. Whenever an image is not found, I replace it with a "fallback" image. Now whenever an image is not found, it will write a console error that the image is not found before replacing it with the fallback.
Any way I can avoid the error? When displaying 100+ images, my entire console log gets filled with errors.
Here is my template:
<img ng-src="{{profileImageUrl}}" fallback-src="img/default-placeholder.png" />
And the directive:
myAppDirectives.directive('fallbackSrc', function () {
var fallbackSrc = {
link: function postLink(scope, iElement, iAttrs) {
iElement.bind('error', function() {
angular.element(this).attr("src", iAttrs.fallbackSrc);
});
}
}
return fallbackSrc;
});
The error I'm getting is a 404 not found for every image that's not available (the site took it down for example)