Fix remote avatar urls when not using cloud storage

This commit is contained in:
Daniel Supernault 2022-07-16 02:47:05 -06:00
parent 012032a20e
commit 672f7c8ce0
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -157,15 +157,19 @@ class Profile extends Model
public function avatarUrl()
{
$url = Cache::remember('avatar:'.$this->id, now()->addYears(1), function () {
$url = Cache::remember('avatar:'.$this->id, 1209600, function () {
$avatar = $this->avatar;
if($avatar->cdn_url) {
return $avatar->cdn_url ?? url('/storage/avatars/default.jpg');
if(substr($avatar->cdn_url, 0, 8) === 'https://') {
return $avatar->cdn_url;
} else {
return url($avatar->cdn_url);
}
}
if($avatar->is_remote) {
return $avatar->cdn_url ?? url('/storage/avatars/default.jpg');
return url('/storage/avatars/default.jpg');
}
$path = $avatar->media_path;