Add file upload for user avatar in admin profile

This commit is contained in:
Andy Miller 2017-03-29 22:43:26 -07:00
parent 5c40337ff0
commit 8fe018a7dd
No known key found for this signature in database
GPG Key ID: E82B8D0EAB94EFB9
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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);
}
}
}