in app/Services/VCard/ImportVCard.php [633:670]
private function importPhoto(Contact $contact, VCard $entry): void
{
if ($entry->PHOTO) {
if (Str::startsWith((string) $entry->PHOTO, 'https://secure.gravatar.com') || Str::startsWith((string) $entry->PHOTO, 'https://www.gravatar.com')) {
// Gravatar
$contact->avatar_gravatar_url = (string) $entry->PHOTO;
} elseif (! Str::startsWith((string) $entry->PHOTO, 'https://')
&& ! Str::startsWith((string) $entry->PHOTO, 'http://')
&& ($contact->avatar_source != 'photo' || empty($contact->avatar_photo_id))) {
// Import photo image
// Skipping in case a photo avatar is already set
$array = [
'account_id' => $contact->account_id,
'contact_id' => $contact->id,
'data' => (string) $entry->PHOTO,
];
if (! is_null($entry->PHOTO['TYPE'])) {
/** @var \Sabre\VObject\Parameter */
$type = $entry->PHOTO['TYPE'];
$array['extension'] = $type->getValue();
}
$photo = app(UploadPhoto::class)->execute($array);
if (! $photo) {
return;
}
app(UpdateAvatar::class)->execute([
'account_id' => $contact->account_id,
'contact_id' => $contact->id,
'source' => 'photo',
'photo_id' => $photo->id,
]);
}
}
}