diff options
| author | Shpuld Shpludson <shp@cock.li> | 2019-03-05 14:40:08 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2019-03-05 14:40:08 +0000 |
| commit | 8cda230fba6d095b6d65b904973ef5a6a279ed60 (patch) | |
| tree | 3ff6b7a9b7138fabf54ca689b3227f45f194cb59 | |
| parent | 3e4d465ebab2196dcacfcae1921d7cf7d74f4a0c (diff) | |
| parent | ff9e55ae4248504345b5ee7935b084defc4cad1c (diff) | |
Merge branch '419-avatar-cropper-png' into 'develop'
Generate cropped avatar image in the original file type
Closes #419
See merge request pleroma/pleroma-fe!640
| -rw-r--r-- | src/components/image_cropper/image_cropper.js | 8 | ||||
| -rw-r--r-- | src/components/user_settings/user_settings.js | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/components/image_cropper/image_cropper.js b/src/components/image_cropper/image_cropper.js index 990c0370..49d51846 100644 --- a/src/components/image_cropper/image_cropper.js +++ b/src/components/image_cropper/image_cropper.js @@ -67,7 +67,7 @@ const ImageCropper = { submit () { this.submitting = true this.avatarUploadError = null - this.submitHandler(this.cropper, this.filename) + this.submitHandler(this.cropper, this.file) .then(() => this.destroy()) .catch((err) => { this.submitError = err @@ -88,14 +88,14 @@ const ImageCropper = { readFile () { const fileInput = this.$refs.input if (fileInput.files != null && fileInput.files[0] != null) { + this.file = fileInput.files[0] let reader = new window.FileReader() reader.onload = (e) => { this.dataUrl = e.target.result this.$emit('open') } - reader.readAsDataURL(fileInput.files[0]) - this.filename = fileInput.files[0].name || 'unknown' - this.$emit('changed', fileInput.files[0], reader) + reader.readAsDataURL(this.file) + this.$emit('changed', this.file, reader) } }, clearError () { diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index d6972737..c0ab759c 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -157,8 +157,8 @@ const UserSettings = { } reader.readAsDataURL(file) }, - submitAvatar (cropper) { - const img = cropper.getCroppedCanvas().toDataURL('image/jpeg') + submitAvatar (cropper, file) { + const img = cropper.getCroppedCanvas().toDataURL(file.type) return this.$store.state.api.backendInteractor.updateAvatar({ params: { img } }).then((user) => { if (!user.error) { this.$store.commit('addNewUsers', [user]) |
