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({
tagName: 'img',
attributeBindings: ['cdnSrc:src'],
import computed from 'ember-addons/ember-computed-decorators';
cdnSrc: function() {
return Discourse.getURLWithCDN(this.get('src'));
}.property('src')
export default Ember.Component.extend({
tagName: '',
@computed('src')
cdnSrc(src) {
return Discourse.getURLWithCDN(src);
}
});

View File

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