From 6468e77445be335f6f752ded75231af1a0acd673 Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Wed, 22 Jan 2025 21:31:36 -0500 Subject: [PATCH] upd: User vCard profile * Add profile image to vCard --- src/Entity/User.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Entity/User.php b/src/Entity/User.php index 1f8067c..58b508f 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -418,6 +418,18 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface public function generateVCard(): string { list($fname, $lname) = explode(' ', $this->name, 2); + $b64image = null; + $fileExt = null; + + if ($this->imageName) { + $fullFileName = dirname(dirname(__DIR__))."/public/{$_ENV['USER_IMAGE_PATH']}/{$this->imageName}"; + $fileExt = strtoupper(pathinfo($fullFileName, PATHINFO_EXTENSION)); + + $b64image = base64_encode( + file_get_contents($fullFileName) + ); + } + return 'BEGIN:VCARD' . "\nVERSION:3.0" . "\nN:{$lname};{$fname}" . @@ -426,6 +438,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface ($this->workPhone ? "\nTEL;TYPE=WORK,VOICE:$this->workPhone" : null) . ($this->email ? "\nEMAIL;TYPE=WORK,INTERNET:$this->email" : null) . "\nREV:" . date('c') . + ($this->imageName ? "\nPHOTO;TYPE={$fileExt};ENCODING=b:{$b64image}" : null) . "\nEND:VCARD"; } }