From 1cb89b037d1f5a7dc7a2ada48fbe1b2b62f6c9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 30 Jun 2015 00:00:18 +0200 Subject: [PATCH 1/2] Simply load the thumbnail as small photo - fixes #936 --- js/contacts.js | 14 +++++++++++--- lib/utils/jsonserializer.php | 7 ------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/js/contacts.js b/js/contacts.js index d5672932..59578525 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -1611,7 +1611,7 @@ OC.Contacts = OC.Contacts || {}; * Set a thumbnail for the contact if a PHOTO property exists */ Contact.prototype.setThumbnail = function($elem, refresh) { - if(!this.data.thumbnail && !refresh) { + if(!this.data.photo && !refresh) { this.getListItemElement().find('.avatar').css('height', '32px'); var name = String(this.getDisplayName()).replace(' ', '').replace(',', ''); this.getListItemElement().find('.avatar').imageplaceholder(name || '#'); @@ -1623,9 +1623,17 @@ OC.Contacts = OC.Contacts || {}; if(!$elem.hasClass('thumbnail') && !refresh) { return; } - if(this.data.thumbnail) { + if(this.data.photo) { $elem.removeClass('thumbnail').find('.avatar').remove(); - $elem.css('background-image', 'url(data:image/png;base64,' + this.data.thumbnail + ')'); + var contactId = this.id || 'new', + backend = this.metadata.backend, + addressBookId = this.metadata.parent; + var url = OC.generateUrl( + 'apps/contacts/addressbook/{backend}/{addressBookId}/contact/{contactId}/photo?maxSize=32', + {backend: backend, addressBookId: addressBookId, contactId: contactId} + ); + + $elem.css('background-image', 'url(' + url + ')'); } else { $elem.addClass('thumbnail'); $elem.removeAttr('style'); diff --git a/lib/utils/jsonserializer.php b/lib/utils/jsonserializer.php index f495c7f8..af8706ba 100644 --- a/lib/utils/jsonserializer.php +++ b/lib/utils/jsonserializer.php @@ -91,13 +91,6 @@ class JSONSerializer { if(isset($contact->PHOTO) || isset($contact->LOGO)) { $details['photo'] = true; - $details['thumbnail'] = Properties::cacheThumbnail( - $contact->getBackend()->name, - $contact->getParent()->getId(), - $contact->getId(), - null, - $contact - ); } foreach($contact->children as $property) { From a62bed78bbedeb6541cd23db6c39082ac4f9af0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 30 Jun 2015 00:01:27 +0200 Subject: [PATCH 2/2] Fixing js syntax error --- js/contacts.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/contacts.js b/js/contacts.js index 59578525..fce8deb3 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -324,7 +324,7 @@ OC.Contacts = OC.Contacts || {}; $elem.find('select.type[name="parameters[TYPE][]"], select.type[name="parameters[X-SERVICE-TYPE]"]') .combobox({ singleclick: true, - classes: ['propertytype', 'float', 'label'], + classes: ['propertytype', 'float', 'label'] }); } }; @@ -556,13 +556,13 @@ OC.Contacts = OC.Contacts || {}; action:'add', name: element, newchecksum: response.data.checksum, - newvalue: value, + newvalue: value }); self.data[element].push({ name: element, value: value, parameters: parameters, - checksum: response.data.checksum, + checksum: response.data.checksum }); } self.propertyContainerFor(obj).data('checksum', response.data.checksum); @@ -572,7 +572,7 @@ OC.Contacts = OC.Contacts || {}; self.pushToUndo({ action: ((obj && obj.defaultValue) || self.data[element].length) ? 'save' : 'add', // FIXME name: element, - newvalue: value, + newvalue: value }); switch(element) { case 'CATEGORIES':