forked from mirror/pixelfed
Update profile model, improve avatarUrl fallback
This commit is contained in:
parent
f6a588f9cf
commit
620ee826d1
1 changed files with 8 additions and 0 deletions
|
@ -160,6 +160,10 @@ class Profile extends Model
|
||||||
$url = Cache::remember('avatar:'.$this->id, 1209600, function () {
|
$url = Cache::remember('avatar:'.$this->id, 1209600, function () {
|
||||||
$avatar = $this->avatar;
|
$avatar = $this->avatar;
|
||||||
|
|
||||||
|
if(!$avatar) {
|
||||||
|
return url('/storage/avatars/default.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
if($avatar->cdn_url) {
|
if($avatar->cdn_url) {
|
||||||
if(substr($avatar->cdn_url, 0, 8) === 'https://') {
|
if(substr($avatar->cdn_url, 0, 8) === 'https://') {
|
||||||
return $avatar->cdn_url;
|
return $avatar->cdn_url;
|
||||||
|
@ -170,6 +174,10 @@ class Profile extends Model
|
||||||
|
|
||||||
$path = $avatar->media_path;
|
$path = $avatar->media_path;
|
||||||
|
|
||||||
|
if(!$path) {
|
||||||
|
return url('/storage/avatars/default.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
if(substr($path, 0, 6) !== 'public') {
|
if(substr($path, 0, 6) !== 'public') {
|
||||||
return url('/storage/avatars/default.jpg');
|
return url('/storage/avatars/default.jpg');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue