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:
commit
377e0fcb07
@ -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 vCard 3.0 the type must be e.g. JPEG or PNG
|
||||||
// For version 4.0 the full mimetype should be used.
|
// For version 4.0 the full mimetype should be used.
|
||||||
// https://tools.ietf.org/html/rfc2426#section-3.1.4
|
// 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)) {
|
if (isset($this->PHOTO)) {
|
||||||
$this->remove('PHOTO');
|
$this->remove('PHOTO');
|
||||||
}
|
}
|
||||||
|
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->add('PHOTO', $photo->data(), ['ENCODING' => 'b', 'TYPE' => $type]);
|
||||||
|
}
|
||||||
$this->setSaved(false);
|
$this->setSaved(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user