mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Check for http or https in avatar value
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
2dd32d8785
commit
7062583710
|
@ -7,6 +7,7 @@ use App\Models\Setting;
|
|||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class UserPresenter
|
||||
|
@ -399,17 +400,25 @@ class UserPresenter extends Presenter
|
|||
public function gravatar()
|
||||
{
|
||||
if ($this->avatar) {
|
||||
|
||||
// Check if it's a google avatar or some external avatar
|
||||
if (Str::startsWith($this->avatar, ['http://', 'https://'])) {
|
||||
return $this->avatar;
|
||||
}
|
||||
|
||||
// Otherwise assume it's an uploaded image
|
||||
return Storage::disk('public')->url('avatars/'.e($this->avatar));
|
||||
}
|
||||
|
||||
if (Setting::getSettings()->load_remote == '1') {
|
||||
if ($this->model->gravatar != '') {
|
||||
|
||||
$gravatar = md5(strtolower(trim($this->model->gravatar)));
|
||||
|
||||
return '//gravatar.com/avatar/'.$gravatar;
|
||||
} elseif ($this->email != '') {
|
||||
$gravatar = md5(strtolower(trim($this->email)));
|
||||
|
||||
} elseif ($this->email != '') {
|
||||
|
||||
$gravatar = md5(strtolower(trim($this->email)));
|
||||
return '//gravatar.com/avatar/'.$gravatar;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue