Additional Backend Avatar Providers #640
Replies: 2 comments 9 replies
-
I personally (just my opinion) don't think this would be very practical and useful, at least for the core functionality of Winter CMS, as user avatars currently are only shown in few places. Maybe plugin approach would be a lot better - if you have plenty of system users/admins and want to give them unique avatars like this then you simply install plugin. I am not sure how easy or simple it would be implement plugin for this admin/avatar section... I am also not sure if it's ok to use https://ui-avatars.com/ service for this because:
|
Beta Was this translation helpful? Give feedback.
-
I think you can already do this technically by adding an accessor; something along the lines of: \Backend\Models\User::extend(function ($model) {
$model->addDynamicMethod('getAvatarAttribute', function () use ($model) {
$key = 'avatar';
// Attempt to load the relationship normally
if ($model->relationLoaded($key)) {
return $this->getRelation($key);
}
if ($model->hasRelation($key)) {
$avatar = $this->getRelationshipFromMethod($key);
}
// Relationship not found,
if (!$avatar) {
// return custom FileModel instance or class that implements the getThumb() method
}
});
}); |
Beta Was this translation helpful? Give feedback.
-
I was wondering if you would be open to adding additional avatar providers other than gravatar to enable an avatar image with initials instead of just a mystery person.
Here's what I've prototyped by using the https://ui-avatars.com service.
Curious on everyone's thoughts and if there's anything else you'd like to see added or supported.
I can send a PR if this is something of interest.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions