From 31eee34d74490e66bfb48c0a5986687413239ebb Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Mon, 19 Oct 2026 23:46:17 +0900 Subject: [PATCH 1/3] Show initials avatar for users without Gravatar when no default image is set When Setting.gravatar_default is blank, request Gravatar with d=404 and replace the image with the built-in initials avatar on the client side if it fails to load, instead of showing the Gravatar default image. Using d=404 rather than overlaying a d=blank image on the initials avatar keeps the markup of registered avatars unchanged and avoids showing the initials through avatars that have transparent areas. Also update the text on the avatar page so that it remains correct when a default avatar is shown instead of the image registered on the avatar server. Co-Authored-By: Claude Opus 5.5 --- app/helpers/avatars_helper.rb | 21 +++++++++-- .../initials_avatar_fallback_controller.js | 21 +++++++++++ config/locales/ar.yml | 6 ++-- config/locales/az.yml | 6 ++-- config/locales/bg.yml | 6 ++-- config/locales/bs.yml | 6 ++-- config/locales/ca.yml | 6 ++-- config/locales/cs.yml | 6 ++-- config/locales/da.yml | 6 ++-- config/locales/de.yml | 6 ++-- config/locales/el.yml | 6 ++-- config/locales/en-GB.yml | 6 ++-- config/locales/en.yml | 2 +- config/locales/es-PA.yml | 6 ++-- config/locales/es.yml | 6 ++-- config/locales/et.yml | 6 ++-- config/locales/eu.yml | 6 ++-- config/locales/fa.yml | 6 ++-- config/locales/fi.yml | 6 ++-- config/locales/fr.yml | 6 ++-- config/locales/gl.yml | 6 ++-- config/locales/he.yml | 6 ++-- config/locales/hr.yml | 6 ++-- config/locales/hu.yml | 6 ++-- config/locales/id.yml | 6 ++-- config/locales/it.yml | 2 +- config/locales/ja.yml | 4 ++- config/locales/ko.yml | 6 ++-- config/locales/lt.yml | 6 ++-- config/locales/lv.yml | 6 ++-- config/locales/mk.yml | 6 ++-- config/locales/mn.yml | 6 ++-- config/locales/nl.yml | 6 ++-- config/locales/no.yml | 6 ++-- config/locales/pl.yml | 6 ++-- config/locales/pt-BR.yml | 6 ++-- config/locales/pt.yml | 6 ++-- config/locales/ro.yml | 6 ++-- config/locales/ru.yml | 6 ++-- config/locales/sk.yml | 6 ++-- config/locales/sl.yml | 6 ++-- config/locales/sq.yml | 6 ++-- config/locales/sr-YU.yml | 6 ++-- config/locales/sr.yml | 6 ++-- config/locales/sv.yml | 4 ++- config/locales/ta-IN.yml | 6 ++-- config/locales/th.yml | 6 ++-- config/locales/tr.yml | 6 ++-- config/locales/uk.yml | 6 ++-- config/locales/vi.yml | 6 ++-- config/locales/zh-TW.yml | 6 ++-- config/locales/zh.yml | 6 ++-- test/helpers/avatars_helper_test.rb | 22 +++++++++++- test/system/avatars_test.rb | 35 +++++++++++++++++++ 54 files changed, 241 insertions(+), 146 deletions(-) create mode 100644 app/javascript/controllers/initials_avatar_fallback_controller.js create mode 100644 test/system/avatars_test.rb diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index cfafc6841..8533b8e82 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -128,6 +128,17 @@ module AvatarsHelper def gravatar_avatar_tag(user, options) options[:default] = Setting.gravatar_default + if options[:default].blank? && user.respond_to?(:initials) && user.initials.present? + # Gravatar responds with 404 if no avatar is registered for the email, + # then the image is replaced with the initials avatar on the client side + options[:default] = '404' + options[:data] = { + controller: 'initials-avatar-fallback', + action: 'error->initials-avatar-fallback#replace', + initials_avatar_fallback_initials_value: user.initials, + initials_avatar_fallback_class_value: initials_avatar_css_class(user, options) + } + end options[:class] = [GravatarHelper::DEFAULT_OPTIONS[:class], options[:class]].compact.join(' ') email = extract_email_from_user(user) @@ -143,13 +154,17 @@ module AvatarsHelper end def initials_avatar_tag(user, options) - size = (options.delete(:size) || GravatarHelper::DEFAULT_OPTIONS[:size]).to_i - - css_class = ["avatar-color-#{user.id % 8}", "s#{size}", options[:class]].compact.join(' ') + css_class = initials_avatar_css_class(user, options) content_tag('span', user.initials, role: 'img', class: css_class, title: options[:title]) end + def initials_avatar_css_class(user, options) + size = (options[:size] || GravatarHelper::DEFAULT_OPTIONS[:size]).to_i + + ["avatar-color-#{user.id % 8}", "s#{size}", options[:class]].compact.join(' ') + end + def extract_email_from_user(user) if user.respond_to?(:mail) user.mail diff --git a/app/javascript/controllers/initials_avatar_fallback_controller.js b/app/javascript/controllers/initials_avatar_fallback_controller.js new file mode 100644 index 000000000..528503788 --- /dev/null +++ b/app/javascript/controllers/initials_avatar_fallback_controller.js @@ -0,0 +1,21 @@ +import { Controller } from "@hotwired/stimulus"; + +export default class extends Controller { + static values = { initials: String, class: String }; + + connect() { + // The image may have failed to load before the controller was connected + const failedToLoad = this.element.complete && this.element.naturalWidth === 0; + if (failedToLoad) this.replace(); + } + + replace() { + const span = document.createElement("span"); + span.setAttribute("role", "img"); + span.className = this.classValue; + span.textContent = this.initialsValue; + if (this.element.title) span.title = this.element.title; + + this.element.replaceWith(span); + } +} diff --git a/config/locales/ar.yml b/config/locales/ar.yml index d33373db8..56031f97c 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -1587,9 +1587,9 @@ ar: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/az.yml b/config/locales/az.yml index af25426c3..133187229 100644 --- a/config/locales/az.yml +++ b/config/locales/az.yml @@ -1670,9 +1670,9 @@ az: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 3f6471db2..b55fba5e0 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -1525,9 +1525,9 @@ bg: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/bs.yml b/config/locales/bs.yml index 2d2f07166..6d2820ce8 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -1573,9 +1573,9 @@ bs: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 06eca259a..348cf12d7 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -1574,9 +1574,9 @@ ca: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/cs.yml b/config/locales/cs.yml index f4f015e8b..22caf3a7c 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -1567,9 +1567,9 @@ cs: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/da.yml b/config/locales/da.yml index 9a89ef04c..514b2ff13 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -1604,9 +1604,9 @@ da: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/de.yml b/config/locales/de.yml index 5977b68e6..1fe31ca22 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1543,9 +1543,9 @@ de: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/el.yml b/config/locales/el.yml index 042ddc682..f3eae6dbd 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -1587,9 +1587,9 @@ el: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 717665de6..76ee283cf 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -1588,9 +1588,9 @@ en-GB: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/en.yml b/config/locales/en.yml index 5b5b8853b..a6e9c4d81 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1400,7 +1400,7 @@ en: text_select_apply_issue_status: "Select issue status" text_avatar_server_config_html: The current avatar server is %{url}. You can configure it in config/configuration.yml. text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated with the user's email address is currently used as the avatar. It can be changed on that site. + text_avatar_from_server_html: The image associated with the user's email address on %{url} is currently used as the avatar. It can be changed on that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. text_avatar_upload_disabled: Uploading an avatar image to Redmine has been disabled by the administrator. diff --git a/config/locales/es-PA.yml b/config/locales/es-PA.yml index cb98b1dca..085f71732 100644 --- a/config/locales/es-PA.yml +++ b/config/locales/es-PA.yml @@ -1618,9 +1618,9 @@ es-PA: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/es.yml b/config/locales/es.yml index 9d65e1b76..1dc75f243 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1654,9 +1654,9 @@ es: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/et.yml b/config/locales/et.yml index 509d456a1..f4152ad86 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -1592,9 +1592,9 @@ et: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/eu.yml b/config/locales/eu.yml index e91bf679a..0437c9096 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -1588,9 +1588,9 @@ eu: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 87b427c3a..d34fb553d 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -1516,9 +1516,9 @@ fa: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/fi.yml b/config/locales/fi.yml index a3a8aa69f..024f51d1e 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -1605,9 +1605,9 @@ fi: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 66d5c3e3d..58f0973d8 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1553,9 +1553,9 @@ fr: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 2b2ed278b..e31e0dd7c 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -1594,9 +1594,9 @@ gl: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/he.yml b/config/locales/he.yml index 8120f6619..395ae2894 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -1592,9 +1592,9 @@ he: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/hr.yml b/config/locales/hr.yml index b5669056b..5a0e3b872 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -1584,9 +1584,9 @@ hr: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/hu.yml b/config/locales/hu.yml index af8d26dc8..21ef1c4fd 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -1522,9 +1522,9 @@ setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/id.yml b/config/locales/id.yml index 038f7db13..31a65da9d 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -1589,9 +1589,9 @@ id: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/it.yml b/config/locales/it.yml index 7cd9b04c1..9d814e535 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1413,7 +1413,7 @@ it: text_select_apply_issue_status: "Seleziona lo stato della segnalazione" text_avatar_server_config_html: "Il server corrente degli avatar è %{url}. È possibile configurarlo in config/configuration.yml." text_avatar_uploaded: L'immagine caricata è attualmente usata come avatar. - text_avatar_from_server_html: L'immagine di %{url} associata all'indirizzo email dell'utente è attualmente usata come avatar. Può essere modificata su quel sito. + text_avatar_from_server_html: The image associated with the user's email address on %{url} is currently used as the avatar. It can be changed on that site. If no image is registered there, a default avatar is shown. text_avatar_initials: L'immagine generata dal nome dell'utente è attualmente usata come avatar. text_avatar_upload_instead: Puoi invece caricare un'immagine da usare. text_avatar_upload_disabled: Il caricamento di un'immagine avatar su Redmine è stato disabilitato dall'amministratore. diff --git a/config/locales/ja.yml b/config/locales/ja.yml index e1ab1c1a4..cc395f28b 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1526,7 +1526,9 @@ ja: setting_avatar_enabled: ユーザーによるアバターの設定を許可 button_change_avatar: アバター変更 text_avatar_uploaded: 現在はアップロードされた画像がアバターとして使用されています。 - text_avatar_from_server_html: 現在は %{url} でユーザーのメールアドレスに関連づけられている画像がアバターとして使用されています。変更はそのサイトで行えます。 + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: 現在はユーザーの名前から生成された画像がアバターとして使用されています。 text_avatar_upload_instead: 代わりに使用する画像をアップロードすることもできます。 text_avatar_upload_disabled: アバター画像のアップロードは管理者によって無効にされています。 diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 6ab8e7528..5080e9791 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -1604,9 +1604,9 @@ ko: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/lt.yml b/config/locales/lt.yml index 78efdd206..56e532191 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -1548,9 +1548,9 @@ lt: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/lv.yml b/config/locales/lv.yml index d31b3ac70..16a7247d6 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -1581,9 +1581,9 @@ lv: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/mk.yml b/config/locales/mk.yml index c53a3d81e..d52de1cda 100644 --- a/config/locales/mk.yml +++ b/config/locales/mk.yml @@ -1587,9 +1587,9 @@ mk: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/mn.yml b/config/locales/mn.yml index 76269673a..241a730af 100644 --- a/config/locales/mn.yml +++ b/config/locales/mn.yml @@ -1587,9 +1587,9 @@ mn: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/nl.yml b/config/locales/nl.yml index edffa1480..d8d00ac8d 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1562,9 +1562,9 @@ nl: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/no.yml b/config/locales/no.yml index 07012b123..682afec79 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -1578,9 +1578,9 @@ setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 44a47da60..bae117601 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1531,9 +1531,9 @@ pl: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index f08c60129..21dd88f10 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1592,9 +1592,9 @@ pt-BR: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 27aa18788..622ef0957 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -1580,9 +1580,9 @@ pt: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/ro.yml b/config/locales/ro.yml index b5d4982e7..09235da2b 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -1582,9 +1582,9 @@ ro: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 9681a6b31..61deb4bb6 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1646,9 +1646,9 @@ ru: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/sk.yml b/config/locales/sk.yml index dda519bda..1352f4a7b 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -1576,9 +1576,9 @@ sk: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 51e1a8d18..e05d772b2 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -1587,9 +1587,9 @@ sl: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/sq.yml b/config/locales/sq.yml index 76c4bef82..41b942fec 100644 --- a/config/locales/sq.yml +++ b/config/locales/sq.yml @@ -1549,9 +1549,9 @@ sq: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/sr-YU.yml b/config/locales/sr-YU.yml index 9a8634db0..4ccec76e1 100644 --- a/config/locales/sr-YU.yml +++ b/config/locales/sr-YU.yml @@ -1589,9 +1589,9 @@ sr-YU: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 8c319d3eb..02aded93f 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -1588,9 +1588,9 @@ sr: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/sv.yml b/config/locales/sv.yml index eb1469e09..2adf06fdb 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -1545,7 +1545,9 @@ sv: setting_avatar_enabled: Tillåt användare att välja sin avatar button_change_avatar: Ändra avatar text_avatar_uploaded: Den uppladdade bilden används just nu som avatar. - text_avatar_from_server_html: 'Bilden från %{url} som hör till användarens e-postadress används just nu som avatar. Den kan bara ändras på den webbplatsen.' + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: Bilden som skapats av användarens namn används just nu som avatar. text_avatar_upload_instead: Du kan ladda upp en bild att användas i stället. text_avatar_upload_disabled: Administratören har stängt av uppladdning av avatarbilder till Redmine. diff --git a/config/locales/ta-IN.yml b/config/locales/ta-IN.yml index 8f0d5aac0..345fdb585 100644 --- a/config/locales/ta-IN.yml +++ b/config/locales/ta-IN.yml @@ -1542,9 +1542,9 @@ ta-IN: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/th.yml b/config/locales/th.yml index 34210867c..c5e3512fb 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -1583,9 +1583,9 @@ th: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 59ea4391b..7e68d2624 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1586,9 +1586,9 @@ tr: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 809a119e8..112fe4c77 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -1575,9 +1575,9 @@ uk: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/vi.yml b/config/locales/vi.yml index d7fbc0734..0f7e3d1c8 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1591,9 +1591,9 @@ vi: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index ebb38dd01..455f5a462 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -1598,9 +1598,9 @@ setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index c29d7f304..20bc9e84b 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1523,9 +1523,9 @@ zh: setting_avatar_enabled: Allow users to set their avatar button_change_avatar: Change avatar text_avatar_uploaded: The uploaded image is currently used as the avatar. - text_avatar_from_server_html: The image from %{url} associated - with the user's email address is currently used as the avatar. It can be changed - on that site. + text_avatar_from_server_html: The image associated with the user's email address on + %{url} is currently used as the avatar. It can be changed on + that site. If no image is registered there, a default avatar is shown. text_avatar_initials: The image generated from the user's name is currently used as the avatar. text_avatar_upload_instead: You can upload an image to use instead. diff --git a/test/helpers/avatars_helper_test.rb b/test/helpers/avatars_helper_test.rb index 94fe0398c..b6d1147ff 100644 --- a/test/helpers/avatars_helper_test.rb +++ b/test/helpers/avatars_helper_test.rb @@ -53,7 +53,7 @@ class AvatarsHelperTest < Redmine::HelperTest def test_avatar_source_info Redmine::Thumbnail.stubs(:convert_available?).returns(true) user = User.find(2) - assert_include 'It can be changed on that site. You can upload an image to use instead.', avatar_source_info(user) + assert_include 'a default avatar is shown. You can upload an image to use instead.', avatar_source_info(user) with_settings :gravatar_enabled => '0' do assert_include 'generated from the user', avatar_source_info(user) end @@ -120,6 +120,26 @@ class AvatarsHelperTest < Redmine::HelperTest end end + def test_avatar_without_default_should_fall_back_to_initials_avatar + with_settings :gravatar_default => '' do + avatar_tag = avatar(User.find_by_mail('jsmith@somenet.foo')) + + assert_include 'default=404', avatar_tag + assert_select_in avatar_tag, 'img[data-controller="initials-avatar-fallback"]' \ + '[data-initials-avatar-fallback-initials-value="JS"]' \ + '[data-initials-avatar-fallback-class-value="avatar-color-2 s24 avatar active"]' + end + end + + def test_avatar_with_default_should_not_fall_back_to_initials_avatar + with_settings :gravatar_default => 'identicon' do + avatar_tag = avatar(User.find_by_mail('jsmith@somenet.foo')) + + assert_include 'default=identicon', avatar_tag + assert_not_include 'initials-avatar-fallback', avatar_tag + end + end + def test_avatar_disabled_should_display_user_initials with_settings :gravatar_enabled => '0' do assert_equal "JS", avatar(User.find_by_mail('jsmith@somenet.foo')) diff --git a/test/system/avatars_test.rb b/test/system/avatars_test.rb new file mode 100644 index 000000000..8775013e4 --- /dev/null +++ b/test/system/avatars_test.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +# Redmine - project management software +# Copyright (C) 2006- Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require_relative '../application_system_test_case' + +class AvatarsTest < ApplicationSystemTestCase + def test_gravatar_without_default_should_fall_back_to_initials_avatar_if_not_found + with_settings :gravatar_enabled => '1', :gravatar_default => '' do + # Requests to /avatar/:hash on Redmine itself respond with 404 + Redmine::Configuration.with 'avatar_server_url' => '' do + log_user('jsmith', 'jsmith') + visit '/users/2' + + assert_selector 'h2 span[role="img"].avatar.avatar-color-2.s50.active', :text => 'JS' + assert_no_selector 'h2 img.gravatar' + end + end + end +end -- 2.55.0