2019-07-02 14:52:47 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import { computed } from '@ember/object';
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
tagName: 'figure',
|
|
|
|
classNames: 'image-file',
|
2019-07-31 00:21:12 +00:00
|
|
|
'data-test-image-file': true,
|
2019-07-02 14:52:47 +00:00
|
|
|
|
|
|
|
src: null,
|
|
|
|
alt: null,
|
|
|
|
size: null,
|
|
|
|
|
|
|
|
// Set by updateImageMeta
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
|
|
|
|
fileName: computed('src', function() {
|
|
|
|
if (!this.src) return;
|
|
|
|
return this.src.includes('/') ? this.src.match(/^.*\/(.*)$/)[1] : this.src;
|
|
|
|
}),
|
|
|
|
|
|
|
|
updateImageMeta(event) {
|
|
|
|
const img = event.target;
|
|
|
|
this.setProperties({
|
|
|
|
width: img.naturalWidth,
|
|
|
|
height: img.naturalHeight,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|