From a94eff5e59718fbef4743b6e115d072fd9eb397a Mon Sep 17 00:00:00 2001 From: Regis Freyd Date: Sun, 28 Jan 2018 08:58:40 -0500 Subject: [PATCH 1/2] Fix avatar being invalid in the Contact API call --- CHANGELOG | 2 +- app/Contact.php | 4 ++-- app/Http/Resources/Contact/Contact.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 479e807559f..7d19b7e5c47 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ UNRELEASED CHANGES: -* +* Fix avatar being invalid in the Contact API call v1.6.2 - 2018-01-25 ------------------- diff --git a/app/Contact.php b/app/Contact.php index 0130d643fe2..a38ecc25f1b 100644 --- a/app/Contact.php +++ b/app/Contact.php @@ -800,7 +800,7 @@ public function getCompletedTasks() * @param int $size * @return string */ - public function getAvatarURL($size = 100) + public function getAvatarURL($size = 110) { // it either returns null or the gravatar url if it's defined if (! $this->has_avatar) { @@ -816,7 +816,7 @@ public function getAvatarURL($size = 100) $avatar_extension = pathinfo($original_avatar_url, PATHINFO_EXTENSION); $resized_avatar = 'avatars/'.$avatar_filename.'_'.$size.'.'.$avatar_extension; - return Storage::disk($this->avatar_location)->url($resized_avatar); + return asset(Storage::disk($this->avatar_location)->url($resized_avatar)); } /** diff --git a/app/Http/Resources/Contact/Contact.php b/app/Http/Resources/Contact/Contact.php index fb0b6168319..18114bf96b3 100644 --- a/app/Http/Resources/Contact/Contact.php +++ b/app/Http/Resources/Contact/Contact.php @@ -57,7 +57,7 @@ public function toArray($request) 'company' => $this->company, ]), 'avatar' => $this->when(! $this->is_partial, [ - 'url' => $this->getAvatarUrl(), + 'url' => $this->getAvatarUrl(110), 'source' => $this->getAvatarSource(), ]), 'food_preferencies' => $this->when(! $this->is_partial, $this->food_preferencies), From d2c0d5da7954ed9d0d64d841887ab4388e1cbab9 Mon Sep 17 00:00:00 2001 From: Regis Freyd Date: Sun, 28 Jan 2018 09:09:29 -0500 Subject: [PATCH 2/2] Fix test --- tests/Unit/ContactTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/ContactTest.php b/tests/Unit/ContactTest.php index 95488031741..e2b9130e69c 100644 --- a/tests/Unit/ContactTest.php +++ b/tests/Unit/ContactTest.php @@ -321,7 +321,7 @@ public function testGetAvatarReturnsPath() $contact->avatar_file_name = 'h0FMvD2cA3r2Q1EtGiv7aq9yl5BoXH2KIenDsoGX.jpg'; $this->assertEquals( - '/storage/avatars/h0FMvD2cA3r2Q1EtGiv7aq9yl5BoXH2KIenDsoGX_100.jpg', + asset('/storage/avatars/h0FMvD2cA3r2Q1EtGiv7aq9yl5BoXH2KIenDsoGX_100.jpg'), $contact->getAvatarURL(100) ); }