summaryrefslogtreecommitdiffstats
path: root/src/components/ContactDetails/ContactDetailsAvatar.vue
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-01-15 12:08:47 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-01-15 12:08:47 +0100
commit77aa4bbdf448ec1d054f3883cbf09b0065db50c8 (patch)
tree712712ba27b5e070ef3979148e0aa4688ce6f2c2 /src/components/ContactDetails/ContactDetailsAvatar.vue
parentac90f097abb32282c3b9603712354351a93d446a (diff)
Max avatar size
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/components/ContactDetails/ContactDetailsAvatar.vue')
-rw-r--r--src/components/ContactDetails/ContactDetailsAvatar.vue22
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)
}
},