use webp in webPreview
This commit is contained in:
parent
4f7d3d5127
commit
fe66e7c769
1 changed files with 25 additions and 9 deletions
|
@ -34,8 +34,10 @@
|
||||||
v-spacer
|
v-spacer
|
||||||
v-btn(text color='primary' @click='openMediaDetails = true') {{$t('common.edit')}}
|
v-btn(text color='primary' @click='openMediaDetails = true') {{$t('common.edit')}}
|
||||||
v-btn(text color='error' @click='remove') {{$t('common.remove')}}
|
v-btn(text color='error' @click='remove') {{$t('common.remove')}}
|
||||||
div(v-if='mediaPreview')
|
div.col-12.ml-3(v-if='mediaPreview')
|
||||||
img.mediaPreview.col-12.ml-3(:src='mediaPreview' :style="{ 'object-position': savedPosition }")
|
picture
|
||||||
|
source(:srcset='mediaPreview("webp")')
|
||||||
|
img.mediaPreview(:src='mediaPreview("jpg")' :style="{ 'object-position': savedPosition }")
|
||||||
span.float-right {{event.media[0].name}}
|
span.float-right {{event.media[0].name}}
|
||||||
v-file-input(
|
v-file-input(
|
||||||
v-else
|
v-else
|
||||||
|
@ -65,13 +67,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
mediaPreview () {
|
|
||||||
if (!this.value.url && !this.value.image) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const url = this.value.image ? URL.createObjectURL(this.value.image) : /^https?:\/\//.test(this.value.url) ? this.value.url : `/media/thumb/${this.value.url}`
|
|
||||||
return url
|
|
||||||
},
|
|
||||||
top () {
|
top () {
|
||||||
return ((this.focalpoint[1] + 1) * 50) + '%'
|
return ((this.focalpoint[1] + 1) * 50) + '%'
|
||||||
},
|
},
|
||||||
|
@ -88,6 +83,27 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
mediaPreview (format) {
|
||||||
|
if (!this.value.url && !this.value.image) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// just uploaded image
|
||||||
|
if (this.value.image) {
|
||||||
|
return URL.createObjectURL(this.value.image)
|
||||||
|
}
|
||||||
|
|
||||||
|
// remote image
|
||||||
|
if (/^https?:\/\//.test(this.value.url)) {
|
||||||
|
return this.value.url
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format === 'jpg') {
|
||||||
|
return `/media/thumb/${this.value.url}`
|
||||||
|
} else {
|
||||||
|
return `/media/thumb/${this.value.url.replace(/.jpg$/, '.webp')}`
|
||||||
|
}
|
||||||
|
},
|
||||||
save () {
|
save () {
|
||||||
this.$emit('input', { url: this.value.url, image: this.value.image, name: this.name || (this.event.title) || '', focalpoint: [...this.focalpoint] })
|
this.$emit('input', { url: this.value.url, image: this.value.image, name: this.name || (this.event.title) || '', focalpoint: [...this.focalpoint] })
|
||||||
this.openMediaDetails = false
|
this.openMediaDetails = false
|
||||||
|
|
Loading…
Reference in a new issue