1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-11-23 19:32:29 +01:00

Prevented a missing avatar from crashing the application

This commit is contained in:
Dan Brown 2017-01-22 12:19:50 +00:00
parent 33d4844f17
commit 380f0f2042
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -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;
}
/**