Feature #42623
closedAdds initials to the list of default Gravatar options
0%
Description
- https://blog.gravatar.com/2025/02/19/initials-avatars-email-signatures/
- https://docs.gravatar.com/api/avatars/images/
The attached patch adds this to the list of available options.
Files
Related issues
Updated by Marius BĂLTEANU 3 months ago
- Related to Feature #29824: Add user initials when Gravatar is disabled added
Updated by Marius BĂLTEANU 3 months ago
Two points to clarify:
1. I'm aware about the privacy discussions from #29824, but being an option that must be configured manually from the administration, I think it is safe.
2. The patch was inspired by the patch added by Felix in the #29824, but I think it is better to use the display name to generate the initials.
Go MAEDA, what do you think?
Updated by Go MAEDA 3 months ago
Marius BĂLTEANU wrote in #note-2:
1. I'm aware about the privacy discussions from #29824, but being an option that must be configured manually from the administration, I think it is safe.
I agree, but I think we should display a warning such as the following below the "Default Gravatar image" setting:
When "Initials" is selected, users' names will be sent to https://www.gravatar.com while displaying user icons."
2. The patch was inspired by the patch added by Felix in the #29824, but I think it is better to use the display name to generate the initials.
I think so too for the following reasons:
- User names are not always displayed with the
firstname lastname
order. Redmine also supports the "lastname firstname". It is easy to generate initials with the order if the display name (User#name
) is used. - Always displaying the first letters of first and last name may cause a privacy problem. For example, when user names are displayed in the
#{login}
style on Redmine, the current implementation reveals two characters of user names that are not visible for non-admin users.
To address the above, I suggest the following implementation.
def initials
name_part1, name_part2 = name.split
if name_part2.present?
name_part1.first + name_part2.first
else
name_part1.first(2)
end
end
Updated by Marius BĂLTEANU 3 months ago
- File 0001-Adds-Initials-to-the-list-of-default-gratavar-option.patch 0001-Adds-Initials-to-the-list-of-default-gratavar-option.patch added
- Target version changed from Candidate for next major release to 6.1.0
Go MAEDA wrote in #note-3:
[...]
I agree, but I think we should display a warning such as the following below the "Default Gravatar image" setting:
When "Initials" is selected, users' names will be sent to https://www.gravatar.com while displaying user icons.
In most of the cases, the message is not really correct because we send only the initials to the Gratavar service. Indeed, there are some cases where initials can be the same with the name.
What to you think about a generic message?
Users' email addresses and initials (when selected) are sent to https://www.gravatar.com to generate their avatars.
[...]
I think so too for the following reasons:
- User names are not always displayed with the
firstname lastname
order. Redmine also supports the "lastname firstname". It is easy to generate initials with the order if the display name (User#name
) is used.- Always displaying the first letters of first and last name may cause a privacy problem. For example, when user names are displayed in the
#{login}
style on Redmine, the current implementation reveals two characters of user names that are not visible for non-admin users.To address the above, I suggest the following implementation.
[...]
I've changed the implementation to generate the initials based on the user display format in order to be more consistent. Please let me know if this works better for you.
I'm assigning this to 6.1.0 to discuss it.
Updated by Go MAEDA 3 months ago
Thank you for updating the patch.
Marius BĂLTEANU wrote in #note-4:
In most of the cases, the message is not really correct because we send only the initials to the Gratavar service. Indeed, there are some cases where initials can be the same with the name.
What to you think about a generic message?
Users' email addresses and initials (when selected) are sent to https://www.gravatar.com to generate their avatars.
Since email addresses are hashed with SHA256 before being sent, it does not cause a privacy issue. A privacy issue only happens when "Initials" is selected, so I think the message should focus on the fact that initials are being sent. I prefer a message like the following:
When "Initials" is selected, users' initials are sent to https://www.gravatar.com to generate their avatars.
I've changed the implementation to generate the initials based on the user display format in order to be more consistent. Please let me know if this works better for you.
The implementation is more sophisticated than the code I suggested in #note-3. However, it needs a slight fix. The value of :initials
for :lastname_firstname
should be '#{lastname.to_s.first}#{firstname.to_s.first}'
(remove the space between the two characters).
Updated by Marius BĂLTEANU 3 months ago
- Assignee set to Marius BĂLTEANU
Go MAEDA wrote in #note-5:
Since email addresses are hashed with SHA256 before being sent, it does not cause a privacy issue. A privacy issue only happens when "Initials" is selected, so I think the message should focus on the fact that initials are being sent. I prefer a message like the following:
[...]
I'm sorry, I totally forgot about the hashing. In this case, I fully agree with you about the message.
I've changed the implementation to generate the initials based on the user display format in order to be more consistent. Please let me know if this works better for you.
The implementation is more sophisticated than the code I suggested in #note-3. However, it needs a slight fix. The value of
:initials
for:lastname_firstname
should be'#{lastname.to_s.first}#{firstname.to_s.first}'
(remove the space between the two characters).
Thanks for pointing this out, I will update the patch accordingly.
Updated by Marius BĂLTEANU 2 months ago
- Status changed from New to Resolved
- Resolution set to Fixed
Change committed with the warning message displayed only when "Initials" is selected.
Updated by Marius BĂLTEANU 2 months ago
- Status changed from Resolved to Closed
Thanks Go MAEDA for adding the locales!
Updated by Go MAEDA about 1 month ago
- Subject changed from Adds initials to the list of default gratavar options to Adds initials to the list of default Gravatar options
Updated by Go MAEDA 11 days ago
- File 42623-fix-no-method-error.patch 42623-fix-no-method-error.patch added
- Status changed from Closed to Reopened
The current implementation raises the following exception when the assignee of an issue is a group. This happens because the code tries to call the initials
method on a Group
object, which does not implement it:
ActionView::Template::Error (undefined method `initials' for an instance of Group): Causes: NoMethodError (undefined method `initials' for an instance of Group) 30: 31: <div class="gravatar-with-child"> 32: <%= author_avatar(@issue.author, :size => "50") %> 33: <%= assignee_avatar(@issue.assigned_to, :size => "22", :class => "gravatar-child") if @issue.assigned_to %> 34: </div> 35: 36: <div data-controller="sticky-issue-header"> app/helpers/avatars_helper.rb:47:in `avatar' app/helpers/avatars_helper.rb:27:in `assignee_avatar' app/views/issues/show.html.erb:33 app/controllers/issues_controller.rb:125:in `block (2 levels) in show' app/controllers/issues_controller.rb:112:in `show' lib/redmine/sudo_mode.rb:78:in `sudo_mode'
The attached patch defines a Group#initials
method to prevent this error.
However, even with this patch, Redmine does not display the initials icon for groups because displaying Gravatar icons for group is not currently supported. Therefore, while the patch avoids the exception, it does not change the visual appearance of group avatars.
Displaying a Gravatar icon for groups is outside the scope of this issue and can be considered as a future enhancement. For now, the priority should be to fix the error.
Updated by Marius BĂLTEANU 10 days ago
Thanks for catching this issue.
What do you think as a quick fix to add the initials
method to Principal
class and return nil
by default in order to force each subclass to define their own logic for initials if they want to display them?
Updated by Go MAEDA 10 days ago
Marius BĂLTEANU wrote in #note-11:
What do you think as a quick fix to add the
initials
method toPrincipal
class and returnnil
by default in order to force each subclass to define their own logic for initials if they want to display them?
I agree. Returning nil
in the Principal class is more consistent with other methods such as Principal#mail
and Principal#mail=
.
Updated by Katsuya HIDAKA 10 days ago
I tested the patch attached to #note-12 locally and confirmed that it works. I also verified that all tests pass. Looks good.
https://github.com/hidakatsuya/redmine/actions/runs/16282340053
Updated by Marius BĂLTEANU 10 days ago
- Status changed from Reopened to Closed
Fix committed, thanks!