Prevented a missing avatar from crashing the application
This commit is contained in:
parent
33d4844f17
commit
380f0f2042
1 changed files with 10 additions and 2 deletions
12
app/User.php
12
app/User.php
|
@ -160,8 +160,16 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
*/
|
||||
public function getAvatar($size = 50)
|
||||
{
|
||||
if ($this->image_id === 0 || $this->image_id === '0' || $this->image_id === null) return baseUrl('/user_avatar.png');
|
||||
return baseUrl($this->avatar->getThumb($size, $size, false));
|
||||
$default = baseUrl('/user_avatar.png');
|
||||
$imageId = $this->image_id;
|
||||
if ($imageId === 0 || $imageId === '0' || $imageId === null) return $default;
|
||||
|
||||
try {
|
||||
$avatar = baseUrl($this->avatar->getThumb($size, $size, false));
|
||||
} catch (\Exception $err) {
|
||||
$avatar = $default;
|
||||
}
|
||||
return $avatar;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue