Project

General

Profile

Actions

Feature #44717

open

Let users choose the colour of their initials avatar from the palette

Feature #44717: Let users choose the colour of their initials avatar from the palette

Added by Yevhen Putsil 22 days ago. Updated about 14 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
UI
Target version:
-
Resolution:

Description

Problem

Since 6.1.0 (#29824) the colour of the initials avatar is derived from user.id % 8 in AvatarsHelper#initials_avatar_tag. The user has no way to influence it, and that has two practical consequences:

  • Two users with the same initials whose ids are congruent modulo 8 get exactly the same avatar: same letters, same colour. The avatar then fails at its main job, telling people apart at a glance in issue lists, on the activity page and in the watchers list, and the collision gets more likely as the user base grows.
  • Users are stuck for good with whatever colour their id happened to produce. Colour is a personal thing, and the only remedy today is an administrator changing the theme for everyone.

Mock-up with fictitious names: two different assignees with the same initials and ids congruent modulo 8 get the same avatar.

Feature #12197 (7.1.0) lets users upload a picture instead, but the initials avatar remains the default, and the only option wherever ImageMagick is missing, uploads are disabled by policy, or users simply do not want a photo. With #44684 it also becomes the fallback for Gravatar users without an image. Most users will therefore keep seeing it, so it is worth making it something they can choose.

Proposal

Add a per-user setting that selects one of the existing palette classes avatar-color-0 to avatar-color-7. The user chooses an index, not a colour value, so:

  • Colours stay CSS classes. Themes keep full control of the actual values, which was the design constraint Felix Schäfer set out in #29824 (inline styles would make it impossible for theme authors to adjust the colours to their theme).
  • No new colour or contrast handling is needed: each class already carries its matching text colour.
  • The default stays user.id % 8, so nothing changes for anyone until they pick a colour.
  • A later extension of the palette, listed as a future improvement in #29824, just becomes a longer swatch row.

UI

On the avatar page introduced by #12197 (/my/avatar, and /users/:id/avatar for administrators), below the preview, a row of radio buttons labelled "Colour". Each option is rendered as the initials avatar itself with the respective avatar-color-N class and the user's own initials, so the user sees the real result, and the current colour is pre-selected. The row is shown whenever the initials avatar is in use or would be the fallback, and unlike the upload form it works without ImageMagick.

If the avatar page is considered upload specific, the same control fits in app/views/users/_preferences.html.erb, which is already shared between My account and the administrator's user form.

Avatar page as it is on trunk (mock-up built from the #12197 template).

The same page with the proposed Colour row. The current colour is pre-selected.

Implementation sketch

  • Migration: add_column :users, :avatar_color, :integer, nullable. A column on users rather than an entry in UserPreference#others, for the same reason #12197 put avatar_id there: avatars are rendered for many different users on every list page, and reading a preference row for each of them would add one query per user.
  • User: add avatar_color to safe_attributes and validate it with inclusion: 0...AvatarsHelper::INITIALS_AVATAR_COLORS, allow_nil: true.
  • AvatarsHelper: a constant INITIALS_AVATAR_COLORS = 8 as the single place where the palette size is defined, and in initials_avatar_tag:
color = user.avatar_color
color = user.id % INITIALS_AVATAR_COLORS unless color && color.between?(0, INITIALS_AVATAR_COLORS - 1)
css_class = ["avatar-color-#{color}", "s#{size}", options[:class]].compact.join(' ')

The range check keeps a stored value from breaking the display if the palette ever shrinks.

  • AvatarsController: a separate action for saving the colour (e.g. PUT /my/avatar/color), because the existing update sits behind check_avatar_available and colour selection must work without ImageMagick.
  • Locale: one new string, field_avatar_color.
  • REST API: expose avatar_color on the user resource, optionally as a follow-up.

Out of scope

  • Random assignment at user creation: not needed, user.id % 8 already spreads the colours and is stable.
  • Free colour input: deliberately excluded, so that themes stay in control and text contrast stays guaranteed.

Files

avatar-page-before.png (52.1 KB) avatar-page-before.png Yevhen Putsil, 2026-11-04 16:48
avatar-page-with-colour-picker.png (77.9 KB) avatar-page-with-colour-picker.png Yevhen Putsil, 2026-11-04 16:48
same-initials-same-colour.png (77.6 KB) same-initials-same-colour.png Yevhen Putsil, 2026-11-04 16:48
after-avatar-page.png (54.5 KB) after-avatar-page.png Ahesh Lakmal, 2026-11-19 00:39
after-avatar-page-saved.png (56.2 KB) after-avatar-page-saved.png Ahesh Lakmal, 2026-11-19 00:39
after-user-page.png (21.2 KB) after-user-page.png Ahesh Lakmal, 2026-11-19 00:39
before-avatar-page.png (43.4 KB) before-avatar-page.png Ahesh Lakmal, 2026-11-19 00:39
before-user-page.png (21.1 KB) before-user-page.png Ahesh Lakmal, 2026-11-19 00:39
44717-initials-avatar-color.patch (15 KB) 44717-initials-avatar-color.patch Ahesh Lakmal, 2026-11-19 00:39

Related issues 1 (0 open — 1 closed)

Related to Redmine - Feature #44723: Increase the number of initials avatar background colors from 8 to 16ClosedGo MAEDAActions

Updated by Yevhen Putsil 22 days ago Actions #1

Related to #29824, #43227, #12197 and #44684.

Updated by Go MAEDA 21 days ago Actions #2

As you pointed out, with the current 8 background colors, two users with the same initials get exactly the same avatar with a probability of 1 in 8 (12.5%).

To mitigate this, I have proposed increasing the number of background colors to 16 in #44723.

Updated by Go MAEDA 21 days ago Actions #3

  • Related to Feature #44723: Increase the number of initials avatar background colors from 8 to 16 added

Updated by Ahesh Lakmal 8 days ago Actions #4

The attached patch implements this on the avatar page (/my/avatar, and /users/:id/avatar for administrators).

  • The palette has 16 colors since #44723, so the user chooses one of avatar-color-0 to avatar-color-15. Colors stay defined in the themes.
  • The choice is stored in a new nullable users.avatar_color column. Users who have not chosen a color keep the color derived from their id.
  • The color can be changed without ImageMagick (PUT /my/avatar/color and PUT /users/:id/avatar/color).
  • The REST API is not changed.

Screenshots before and after the patch are attached.

Updated by Go MAEDA 6 days ago Actions #5

Thank you for the patch and the screenshots. However, I am not in favor of adding this feature.

The initials avatar is a fallback for users who have not set an avatar image. Users who want to be distinguished can set an image, either on Gravatar or as a local avatar, which will be available in Redmine 7.1.0 (#12197). Users who have not set an image are unlikely to choose a color either, so I don't think this feature would help most of them.

The benefit is mostly a matter of appearance, but the cost is not small: a new column in the users table, new routes and controller actions, and additional UI. avatar_id was added as a column because it is essential to local avatars, but I don't think a color preference justifies the same.

In addition, #44723 increased the number of background colors from 8 to 16, which halved the chance that users with the same initials get identical avatars. Local avatars require ImageMagick, but it is also used to generate thumbnails of attachments, so I think most Redmine installations can already use them.

Updated by Ahesh Lakmal about 14 hours ago Actions #6

Thank you for the review and the explanation. That makes sense, especially with local avatars in 7.1.0 and the 16 colors from #44723.

Actions

Also available in: PDF Atom