mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Prevented a missing avatar from crashing the application
This commit is contained in:
parent
33d4844f17
commit
380f0f2042
12
app/User.php
12
app/User.php
@ -160,8 +160,16 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||||||
*/
|
*/
|
||||||
public function getAvatar($size = 50)
|
public function getAvatar($size = 50)
|
||||||
{
|
{
|
||||||
if ($this->image_id === 0 || $this->image_id === '0' || $this->image_id === null) return baseUrl('/user_avatar.png');
|
$default = baseUrl('/user_avatar.png');
|
||||||
return baseUrl($this->avatar->getThumb($size, $size, false));
|
$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 New Issue
Block a user