From 620ee826d109a5c3718578295a7cb6f6f0e36358 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 8 Feb 2023 01:27:32 -0700 Subject: [PATCH] Update profile model, improve avatarUrl fallback --- app/Profile.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Profile.php b/app/Profile.php index f02144f0..45052088 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -160,6 +160,10 @@ class Profile extends Model $url = Cache::remember('avatar:'.$this->id, 1209600, function () { $avatar = $this->avatar; + if(!$avatar) { + return url('/storage/avatars/default.jpg'); + } + if($avatar->cdn_url) { if(substr($avatar->cdn_url, 0, 8) === 'https://') { return $avatar->cdn_url; @@ -170,6 +174,10 @@ class Profile extends Model $path = $avatar->media_path; + if(!$path) { + return url('/storage/avatars/default.jpg'); + } + if(substr($path, 0, 6) !== 'public') { return url('/storage/avatars/default.jpg'); }