github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/components/image-file.js (about) 1 import Component from '@ember/component'; 2 import { computed } from '@ember/object'; 3 import { classNames, tagName } from '@ember-decorators/component'; 4 import classic from 'ember-classic-decorator'; 5 6 @classic 7 @tagName('figure') 8 @classNames('image-file') 9 export default class ImageFile extends Component { 10 'data-test-image-file' = true; 11 12 src = null; 13 alt = null; 14 size = null; 15 16 // Set by updateImageMeta 17 width = 0; 18 height = 0; 19 20 @computed('src') 21 get fileName() { 22 if (!this.src) return undefined; 23 return this.src.includes('/') ? this.src.match(/^.*\/(.*)$/)[1] : this.src; 24 } 25 26 updateImageMeta(event) { 27 const img = event.target; 28 this.setProperties({ 29 width: img.naturalWidth, 30 height: img.naturalHeight, 31 }); 32 } 33 }