mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Image width/height is catched correctly without cropping
This commit is contained in:
parent
585d32ea70
commit
c304b74f17
@ -9,7 +9,7 @@
|
|||||||
@vdropzone-file-added="fileAdded"
|
@vdropzone-file-added="fileAdded"
|
||||||
>
|
>
|
||||||
<loading-spinner v-if="isLoadingImage" />
|
<loading-spinner v-if="isLoadingImage" />
|
||||||
<base-icon v-else name="image" />
|
<base-icon v-else-if="!hasImage" name="image" />
|
||||||
<base-button
|
<base-button
|
||||||
v-if="hasImage"
|
v-if="hasImage"
|
||||||
icon="trash"
|
icon="trash"
|
||||||
@ -87,8 +87,18 @@ export default {
|
|||||||
onUnSupportedFormat(status, message) {
|
onUnSupportedFormat(status, message) {
|
||||||
this.$toast.error(status, message)
|
this.$toast.error(status, message)
|
||||||
},
|
},
|
||||||
fileAdded(file) {
|
addImageProcess(src) {
|
||||||
this.$emit('addImageAspectRatio', file.width / file.height || 1.0)
|
return new Promise((resolve, reject) => {
|
||||||
|
const img = new Image()
|
||||||
|
img.onload = () => resolve(img)
|
||||||
|
img.onerror = reject
|
||||||
|
img.src = src
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async fileAdded(file) {
|
||||||
|
const imageURL = URL.createObjectURL(file)
|
||||||
|
const image = await this.addImageProcess(imageURL)
|
||||||
|
this.$emit('addImageAspectRatio', image.width / image.height || 1.0)
|
||||||
this.$emit('addHeroImage', file)
|
this.$emit('addHeroImage', file)
|
||||||
this.$emit('addImageType', file.type)
|
this.$emit('addImageType', file.type)
|
||||||
this.file = file
|
this.file = file
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user