1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-30 19:52:17 +01:00

Merge pull request #1112 from gvde/fix-4.0-photo

Use data: URI for vcard 4.0 PHOTO.
This commit is contained in:
Thomas Müller 2016-02-29 13:12:02 +01:00
commit 377e0fcb07

View File

@ -456,16 +456,17 @@ class Contact extends VObject\VCard implements IPIMObject {
// For vCard 3.0 the type must be e.g. JPEG or PNG
// For version 4.0 the full mimetype should be used.
// https://tools.ietf.org/html/rfc2426#section-3.1.4
if (strval($this->VERSION) === '4.0') {
$type = $photo->mimeType();
} else {
$type = explode('/', $photo->mimeType());
$type = strtoupper(array_pop($type));
}
if (isset($this->PHOTO)) {
$this->remove('PHOTO');
}
$this->add('PHOTO', $photo->data(), ['ENCODING' => 'b', 'TYPE' => $type]);
if (strval($this->VERSION) === '4.0') {
$type = $photo->mimeType();
$this->add('PHOTO', 'data:'.$type.';base64,'.base64_encode($photo->data()));
} else {
$type = explode('/', $photo->mimeType());
$type = strtoupper(array_pop($type));
$this->add('PHOTO', $photo->data(), ['ENCODING' => 'b', 'TYPE' => $type]);
}
$this->setSaved(false);
return true;