mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-11 12:52:15 +00:00
40 lines
703 B
Vue
40 lines
703 B
Vue
<template>
|
|
<img class="file" :src="src" @error="replaceByOriginal" alt="" />
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'ImageFile',
|
|
props: [
|
|
'file'
|
|
],
|
|
watch: {
|
|
'file': function () {
|
|
this.getSrc()
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
src: undefined,
|
|
}
|
|
},
|
|
methods: {
|
|
replaceByOriginal() {
|
|
this.src = this.file.data.attributes.file_url
|
|
},
|
|
getSrc() {
|
|
if (this.file.data.attributes.mimetype === 'svg') {
|
|
this.src = this.file.data.attributes.file_url
|
|
} else if (window.innerWidth > 1280) {
|
|
this.src = this.file.data.attributes.thumbnail.xl
|
|
} else {
|
|
this.src = this.file.data.attributes.thumbnail.lg
|
|
}
|
|
}
|
|
},
|
|
created() {
|
|
this.getSrc()
|
|
}
|
|
}
|
|
</script>
|