Blessenm's solution was great, but it modifies the model itself. We did not want to do this, so we created a component called a “secure image” that adds a class to the break. With this class on broken images, we can use css to remove or modify a broken image.
{{safe-image src=product_link}}
with this component code: import Ember from 'ember';
App.SafeImageComponent = Ember.Component.extend({ tagName: 'img', attributeBindings: ['src'], classNameBindings: ['isBroken:broken'], isBroken: false, didInsertElement: function() { this.$().on('error', function() { this.set('isBroken', true); }.bind(this)); }, willDestroyElement: function(){ this.$().off(); } });
And added this css to either completely remove the image or replace it with one of our options:
img.broken { display: none; content:url("http://imgur.com/SZ8Cm.jpg"); }
source share