cdn-img will render nothing if src is null

This commit is contained in:
Neil Lalonde 2017-03-15 13:30:29 -04:00
parent c423544208
commit 5c4f37a24e
2 changed files with 11 additions and 6 deletions

View File

@ -1,8 +1,10 @@
export default Ember.Component.extend({ import computed from 'ember-addons/ember-computed-decorators';
tagName: 'img',
attributeBindings: ['cdnSrc:src'],
cdnSrc: function() { export default Ember.Component.extend({
return Discourse.getURLWithCDN(this.get('src')); tagName: '',
}.property('src')
@computed('src')
cdnSrc(src) {
return Discourse.getURLWithCDN(src);
}
}); });

View File

@ -0,0 +1,3 @@
{{#if src}}
<img src={{cdnSrc}} class={{class}}>
{{/if}}