mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Add file upload for user avatar in admin profile
This commit is contained in:
parent
5c40337ff0
commit
8fe018a7dd
|
|
@ -8,6 +8,13 @@ form:
|
|||
type: userinfo
|
||||
size: large
|
||||
|
||||
avatar:
|
||||
type: file
|
||||
size: large
|
||||
destination: 'user://accounts/avatars'
|
||||
multiple: false
|
||||
random_name: true
|
||||
|
||||
content:
|
||||
type: section
|
||||
title: PLUGIN_ADMIN.ACCOUNT
|
||||
|
|
|
|||
|
|
@ -239,4 +239,20 @@ class User extends Data
|
|||
{
|
||||
return $this->authorize($action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the User's avatar URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function avatarUrl()
|
||||
{
|
||||
if ($this->avatar) {
|
||||
$avatar = $this->avatar;
|
||||
$avatar = array_shift($avatar);
|
||||
return Grav::instance()['base_url'] . '/' . $avatar['path'];
|
||||
} else {
|
||||
return 'https://www.gravatar.com/avatar/' . md5($this->email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user