diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-01-15 12:08:47 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-01-15 12:08:47 +0100 |
commit | 77aa4bbdf448ec1d054f3883cbf09b0065db50c8 (patch) | |
tree | 712712ba27b5e070ef3979148e0aa4688ce6f2c2 /src | |
parent | ac90f097abb32282c3b9603712354351a93d446a (diff) |
Max avatar size
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/ContactDetails/ContactDetailsAvatar.vue | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/components/ContactDetails/ContactDetailsAvatar.vue b/src/components/ContactDetails/ContactDetailsAvatar.vue index eec04eb0..05273434 100644 --- a/src/components/ContactDetails/ContactDetailsAvatar.vue +++ b/src/components/ContactDetails/ContactDetailsAvatar.vue @@ -76,17 +76,21 @@ export default { processFile(event) { if (event.target.files) { let file = event.target.files[0] - let reader = new FileReader() - let self = this - // check if photo property exists to decide whether to add/update it - reader.onload = function(e) { - self.contact.photo - ? self.contact.photo = reader.result - : self.contact.vCard.addPropertyWithValue('photo', reader.result) + if (file.size && file.size <= 1 * 1024 * 1024) { + let reader = new FileReader() + let self = this + // check if photo property exists to decide whether to add/update it + reader.onload = function(e) { + self.contact.photo + ? self.contact.photo = reader.result + : self.contact.vCard.addPropertyWithValue('photo', reader.result) - self.$store.dispatch('updateContact', self.contact) + self.$store.dispatch('updateContact', self.contact) + } + reader.readAsDataURL(file) + } else { + OC.Notification.showTemporary(t('contacts', 'Image is too big (max 1MB).')) } - reader.readAsDataURL(file) } }, |