2019-07-02 14:52:47 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import { computed } from '@ember/object';
|
2022-03-08 17:28:36 +00:00
|
|
|
import {
|
|
|
|
classNames,
|
|
|
|
tagName,
|
|
|
|
attributeBindings,
|
|
|
|
} from '@ember-decorators/component';
|
2020-06-10 13:49:16 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2019-07-02 14:52:47 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
@tagName('figure')
|
|
|
|
@classNames('image-file')
|
2022-03-08 17:28:36 +00:00
|
|
|
@attributeBindings('data-test-image-file')
|
2020-06-10 13:49:16 +00:00
|
|
|
export default class ImageFile extends Component {
|
|
|
|
'data-test-image-file' = true;
|
2019-07-02 14:52:47 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
src = null;
|
|
|
|
alt = null;
|
|
|
|
size = null;
|
2019-07-02 14:52:47 +00:00
|
|
|
|
|
|
|
// Set by updateImageMeta
|
2020-06-10 13:49:16 +00:00
|
|
|
width = 0;
|
|
|
|
height = 0;
|
2019-07-02 14:52:47 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('src')
|
|
|
|
get fileName() {
|
2020-06-10 14:07:16 +00:00
|
|
|
if (!this.src) return undefined;
|
2019-07-02 14:52:47 +00:00
|
|
|
return this.src.includes('/') ? this.src.match(/^.*\/(.*)$/)[1] : this.src;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2019-07-02 14:52:47 +00:00
|
|
|
|
|
|
|
updateImageMeta(event) {
|
|
|
|
const img = event.target;
|
|
|
|
this.setProperties({
|
|
|
|
width: img.naturalWidth,
|
|
|
|
height: img.naturalHeight,
|
|
|
|
});
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|