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
2019-11-12 11:09:47 -05:00

14 lines
No EOL
405 B
JavaScript

/**
* 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);
});
}
};
});