mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
image type in frontend
This commit is contained in:
parent
4a16af10ba
commit
664d3d2c42
@ -19,6 +19,7 @@
|
|||||||
:class="[formData.imageBlurred && '--blur-image']"
|
:class="[formData.imageBlurred && '--blur-image']"
|
||||||
@addHeroImage="addHeroImage"
|
@addHeroImage="addHeroImage"
|
||||||
@addImageAspectRatio="addImageAspectRatio"
|
@addImageAspectRatio="addImageAspectRatio"
|
||||||
|
@addImageType="addImageType"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<div v-if="formData.image" class="blur-toggle">
|
<div v-if="formData.image" class="blur-toggle">
|
||||||
@ -84,7 +85,11 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const { title, content, image } = this.contribution
|
const { title, content, image } = this.contribution
|
||||||
const { sensitive: imageBlurred = false, aspectRatio: imageAspectRatio = null } = image || {}
|
const {
|
||||||
|
sensitive: imageBlurred = false,
|
||||||
|
aspectRatio: imageAspectRatio = null,
|
||||||
|
type: imageType = null,
|
||||||
|
} = image || {}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
links,
|
links,
|
||||||
@ -93,6 +98,7 @@ export default {
|
|||||||
content: content || '',
|
content: content || '',
|
||||||
image: image || null,
|
image: image || null,
|
||||||
imageAspectRatio,
|
imageAspectRatio,
|
||||||
|
imageType,
|
||||||
imageBlurred,
|
imageBlurred,
|
||||||
},
|
},
|
||||||
formSchema: {
|
formSchema: {
|
||||||
@ -125,6 +131,7 @@ export default {
|
|||||||
if (this.imageUpload) {
|
if (this.imageUpload) {
|
||||||
image.upload = this.imageUpload
|
image.upload = this.imageUpload
|
||||||
image.aspectRatio = this.formData.imageAspectRatio
|
image.aspectRatio = this.formData.imageAspectRatio
|
||||||
|
image.type = this.formData.imageType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.loading = true
|
this.loading = true
|
||||||
@ -173,6 +180,9 @@ export default {
|
|||||||
addImageAspectRatio(aspectRatio) {
|
addImageAspectRatio(aspectRatio) {
|
||||||
this.formData.imageAspectRatio = aspectRatio
|
this.formData.imageAspectRatio = aspectRatio
|
||||||
},
|
},
|
||||||
|
addImageType(imageType) {
|
||||||
|
this.formData.imageType = imageType
|
||||||
|
},
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
User: {
|
User: {
|
||||||
|
|||||||
@ -90,6 +90,7 @@ export default {
|
|||||||
fileAdded(file) {
|
fileAdded(file) {
|
||||||
this.$emit('addImageAspectRatio', file.width / file.height || 1.0)
|
this.$emit('addImageAspectRatio', file.width / file.height || 1.0)
|
||||||
this.$emit('addHeroImage', file)
|
this.$emit('addHeroImage', file)
|
||||||
|
this.$emit('addImageType', file.type)
|
||||||
this.file = file
|
this.file = file
|
||||||
if (this.file.type === 'image/jpeg') this.imageCanBeCropped = true
|
if (this.file.type === 'image/jpeg') this.imageCanBeCropped = true
|
||||||
this.$nextTick((this.isLoadingImage = false))
|
this.$nextTick((this.isLoadingImage = false))
|
||||||
@ -113,9 +114,10 @@ export default {
|
|||||||
cropImage() {
|
cropImage() {
|
||||||
this.isLoadingImage = true
|
this.isLoadingImage = true
|
||||||
|
|
||||||
const onCropComplete = (aspectRatio, imageFile) => {
|
const onCropComplete = (aspectRatio, imageFile, imageType) => {
|
||||||
this.$emit('addImageAspectRatio', aspectRatio)
|
this.$emit('addImageAspectRatio', aspectRatio)
|
||||||
this.$emit('addHeroImage', imageFile)
|
this.$emit('addHeroImage', imageFile)
|
||||||
|
this.$emit('addImageType', imageType)
|
||||||
this.$nextTick((this.isLoadingImage = false))
|
this.$nextTick((this.isLoadingImage = false))
|
||||||
this.closeCropper()
|
this.closeCropper()
|
||||||
}
|
}
|
||||||
@ -125,7 +127,7 @@ export default {
|
|||||||
canvas.toBlob((blob) => {
|
canvas.toBlob((blob) => {
|
||||||
const imageAspectRatio = canvas.width / canvas.height
|
const imageAspectRatio = canvas.width / canvas.height
|
||||||
const croppedImageFile = new File([blob], this.file.name, { type: this.file.type })
|
const croppedImageFile = new File([blob], this.file.name, { type: this.file.type })
|
||||||
onCropComplete(imageAspectRatio, croppedImageFile)
|
onCropComplete(imageAspectRatio, croppedImageFile, 'image/jpeg')
|
||||||
}, 'image/jpeg')
|
}, 'image/jpeg')
|
||||||
} else {
|
} else {
|
||||||
// TODO: use cropped file instead of original file
|
// TODO: use cropped file instead of original file
|
||||||
@ -140,6 +142,7 @@ export default {
|
|||||||
deleteImage() {
|
deleteImage() {
|
||||||
this.$emit('addHeroImage', null)
|
this.$emit('addHeroImage', null)
|
||||||
this.$emit('addImageAspectRatio', null)
|
this.$emit('addImageAspectRatio', null)
|
||||||
|
this.$emit('addImageType', null)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,7 @@ export const postFragment = gql`
|
|||||||
url
|
url
|
||||||
sensitive
|
sensitive
|
||||||
aspectRatio
|
aspectRatio
|
||||||
|
type
|
||||||
}
|
}
|
||||||
author {
|
author {
|
||||||
...user
|
...user
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user