From 1c40d3cfa552c9308ee7cdc0c645b2ae71bcbfb4 Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Sat, 12 Nov 2016 21:13:29 +0000 Subject: [PATCH] Fixed server crashing if avatar can't be found --- app/Http/Controllers/Api/Web/ArtistsController.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/Web/ArtistsController.php b/app/Http/Controllers/Api/Web/ArtistsController.php index 6ef54fd0..13763726 100644 --- a/app/Http/Controllers/Api/Web/ArtistsController.php +++ b/app/Http/Controllers/Api/Web/ArtistsController.php @@ -172,8 +172,18 @@ class ArtistsController extends ApiControllerBase ]; } - $palette = ColorThief::getPalette($user->getAvatarUrl(Image::SMALL), 2); - $formatted_palette = array_map("Helpers::rgb2hex", $palette); + $formatted_palette = [ + "#ffffff", + "#ffffff", + "#ffffff" + ]; + + try { + $palette = ColorThief::getPalette($user->getAvatarUrl(Image::SMALL), 2); + $formatted_palette = array_map("Helpers::rgb2hex", $palette); + } catch (Exception $e) { + // We failed to get the image, oh well + } $followers = Follower::where('artist_id', $user->id) ->count();