Skip to content

Conversation

@datlechin
Copy link
Contributor

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

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Required changes:

  • Related documentation PR: (Remove if irrelevant)

@datlechin datlechin requested a review from a team as a code owner November 24, 2024 09:41
@imorland
Copy link
Member

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 🙏

Copilot AI review requested due to automatic review settings December 22, 2025 04:36
Copy link

Copilot AI left a 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 originalAvatarUrl attribute 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.

Copy link

Copilot AI left a 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.

Copy link

Copilot AI left a 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.

datlechin and others added 2 commits December 26, 2025 11:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a 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.

@datlechin
Copy link
Contributor Author

@imorland, I’ve completed the work on this PR. Should I include the Gravatar driver along with the default driver in the core?

@imorland imorland added this to the 2.0.0-beta.6 milestone Dec 29, 2025
Copy link
Member

@imorland imorland left a 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?

datlechin added a commit to datlechin/flarum-docs that referenced this pull request Dec 30, 2025
Documents the new avatar driver system introduced in flarum/framework#4130.
Includes implementation guide, examples, and admin configuration.
datlechin added a commit to datlechin/flarum-docs that referenced this pull request Dec 30, 2025
Documents the new avatar driver system introduced in flarum/framework#4130.
Includes implementation guide, examples, and admin configuration.
@datlechin
Copy link
Contributor Author

@imorland I’ve opened the pull request in flarum. I’ll also open another pull request to add Gravatar support to the core when this PR was merged

@datlechin datlechin requested a review from imorland December 30, 2025 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants