This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/fallback-src.js

14 lines
405 B
JavaScript
Raw Normal View History

2019-11-12 16:09:47 +00:00
/**
* Adds a fallback-src attribute, which is used as the source for an <img> tag if the main
* image fails to load.
*/
angular.module('quay').directive('fallbackSrc', function () {
return {
restrict: 'A',
link: function postLink(scope, element, attributes) {
element.bind('error', function() {
angular.element(this).attr("src", attributes.fallbackSrc);
});
}
};
});