Use other default avatar, not in the avatars directory

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-20 07:34:40 +01:00
parent c4e7448d31
commit 8fc5c0b5be
3 changed files with 11 additions and 8 deletions

View file

@ -452,7 +452,6 @@ class SettingsController extends Controller
} }
if ($request->input('restore_default_avatar') == '1') { if ($request->input('restore_default_avatar') == '1') {
Setting::restoreDefaultAvatar();
$setting->default_avatar = 'default.png'; $setting->default_avatar = 'default.png';
} }
} }

View file

@ -445,26 +445,30 @@ class UserPresenter extends Presenter
return Storage::disk('public')->url('avatars/'.e($this->avatar)); return Storage::disk('public')->url('avatars/'.e($this->avatar));
} }
// If there is a default avatar
if (Setting::getSettings()->default_avatar!= '') { // If the default is system default
if (Setting::getSettings()->default_avatar == 'default.png') {
return Storage::disk('public')->url('default.png');
}
// If there is a custom default avatar
if (Setting::getSettings()->default_avatar != '') {
return Storage::disk('public')->url('avatars/'.e(Setting::getSettings()->default_avatar)); return Storage::disk('public')->url('avatars/'.e(Setting::getSettings()->default_avatar));
} }
// Fall back to Gravatar if the settings allow loading remote scripts // If there is no default and no custom avatar, check for gravatar
if (Setting::getSettings()->load_remote == '1') { if ((Setting::getSettings()->load_remote == '1') && (Setting::getSettings()->default_avatar == '')) {
if ($this->model->gravatar != '') {
if ($this->model->gravatar != '') {
$gravatar = md5(strtolower(trim($this->model->gravatar))); $gravatar = md5(strtolower(trim($this->model->gravatar)));
return '//gravatar.com/avatar/'.$gravatar; return '//gravatar.com/avatar/'.$gravatar;
} elseif ($this->email != '') { } elseif ($this->email != '') {
$gravatar = md5(strtolower(trim($this->email))); $gravatar = md5(strtolower(trim($this->email)));
return '//gravatar.com/avatar/'.$gravatar; return '//gravatar.com/avatar/'.$gravatar;
} }
} }
return false; return false;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB