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