-
-
Notifications
You must be signed in to change notification settings - Fork 861
feat: add support for customizable user avatar drivers #4130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
Conversation
|
Hey @datlechin sorry this has been dormant for so long. Do you have any interest in continuing user avatar drivers? If so, please would you rebase and resolve the conflicts here? I'd really like to include this before the 2.0 stable release if possible 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request introduces a customizable avatar driver system that allows extensions to provide alternative avatar sources (e.g., Gravatar) when users don't have uploaded avatars. The implementation mirrors the existing display name driver pattern.
Key Changes:
- Added avatar driver interface and default implementation that returns null for users without custom avatars
- Introduced
originalAvatarUrlattribute to distinguish between uploaded avatars and driver-generated ones - Extended admin UI to allow configuring avatar drivers when multiple options are available
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
framework/core/src/User/UserServiceProvider.php |
Registers avatar driver system with container bindings and default driver |
framework/core/src/User/User.php |
Adds avatar driver property, setter method, and modified getAvatarUrlAttribute to use driver as fallback |
framework/core/src/User/Avatar/DriverInterface.php |
New interface defining the contract for avatar drivers |
framework/core/src/User/Avatar/DefaultDriver.php |
Default implementation returning null when no custom avatar exists |
framework/core/src/Extend/User.php |
Extends User extender with avatarDriver() method for registering custom drivers |
framework/core/src/Api/Resource/UserResource.php |
Adds originalAvatarUrl field to API exposing the raw avatar_url attribute |
framework/core/src/Admin/Content/AdminPayload.php |
Includes available avatar drivers in admin payload for UI configuration |
framework/core/locale/core.yml |
Adds translation keys for avatar driver settings in admin basics page |
framework/core/js/src/forum/components/AvatarEditor.js |
Updates to use originalAvatarUrl() for detecting uploaded avatars |
framework/core/js/src/common/models/User.tsx |
Adds originalAvatarUrl() accessor method to User model |
framework/core/js/src/admin/components/BasicsPage.tsx |
Adds avatar driver selection UI when multiple drivers available |
framework/core/js/src/admin/AdminApplication.tsx |
Adds avatarDrivers to TypeScript interface for admin data |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@imorland, I’ve completed the work on this PR. Should I include the Gravatar driver along with the default driver in the core? |
imorland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @datlechin this looks good to me.
Yes, let's include gravatar support in core. I think it would be used by some communities, and admins can always choose to switch from 'classic' to gravatar as they wish. I don't think the overhead would be too much here.
I think it best to add that as a seperate PR tho, rather than in this one.
Before I merge this, would you please create an counterpart PR to https://github.com/flarum/docs so that developers can see how to use it?
Documents the new avatar driver system introduced in flarum/framework#4130. Includes implementation guide, examples, and admin configuration.
Documents the new avatar driver system introduced in flarum/framework#4130. Includes implementation guide, examples, and admin configuration.
This pull request introduces a new avatar driver system. The changes include adding support for different avatar drivers, updating the user model to accommodate these changes, and modifying relevant components to utilize the new avatar driver system.
Fixes #0000
Changes proposed in this pull request:
Reviewers should focus on:
Screenshot
Necessity
Confirmed
composer test).Required changes: