require('./bootstrap'); $(".mal-img").not(".mal-img-error").on("error", function() { if ( ! $(this).hasClass("mal-img-error") ) { this.src = $(this).data("img-src"); } $(this).addClass('mal-img-error'); // prevents loops });