Project

General

Profile

Feature #44684 » 0001-Show-initials-avatar-for-users-without-Gravatar-when.patch

Go MAEDA, 2026-10-27 10:08

View differences:

app/helpers/avatars_helper.rb
128 128

  
129 129
  def gravatar_avatar_tag(user, options)
130 130
    options[:default] = Setting.gravatar_default
131
    if options[:default].blank? && user.respond_to?(:initials) && user.initials.present?
132
      # Gravatar responds with 404 if no avatar is registered for the email,
133
      # then the image is replaced with the initials avatar on the client side
134
      options[:default] = '404'
135
      options[:data] = {
136
        controller: 'initials-avatar-fallback',
137
        action: 'error->initials-avatar-fallback#replace',
138
        initials_avatar_fallback_initials_value: user.initials,
139
        initials_avatar_fallback_class_value: initials_avatar_css_class(user, options)
140
      }
141
    end
131 142
    options[:class] = [GravatarHelper::DEFAULT_OPTIONS[:class], options[:class]].compact.join(' ')
132 143

  
133 144
    email = extract_email_from_user(user)
......
143 154
  end
144 155

  
145 156
  def initials_avatar_tag(user, options)
146
    size = (options.delete(:size) || GravatarHelper::DEFAULT_OPTIONS[:size]).to_i
147

  
148
    css_class = ["avatar-color-#{user.id % 8}", "s#{size}", options[:class]].compact.join(' ')
157
    css_class = initials_avatar_css_class(user, options)
149 158

  
150 159
    content_tag('span', user.initials, role: 'img', class: css_class, title: options[:title])
151 160
  end
152 161

  
162
  def initials_avatar_css_class(user, options)
163
    size = (options[:size] || GravatarHelper::DEFAULT_OPTIONS[:size]).to_i
164

  
165
    ["avatar-color-#{user.id % 8}", "s#{size}", options[:class]].compact.join(' ')
166
  end
167

  
153 168
  def extract_email_from_user(user)
154 169
    if user.respond_to?(:mail)
155 170
      user.mail
app/javascript/controllers/initials_avatar_fallback_controller.js
1
import { Controller } from "@hotwired/stimulus";
2

  
3
export default class extends Controller {
4
  static values = { initials: String, class: String };
5

  
6
  connect() {
7
    // The image may have failed to load before the controller was connected
8
    const failedToLoad = this.element.complete && this.element.naturalWidth === 0;
9
    if (failedToLoad) this.replace();
10
  }
11

  
12
  replace() {
13
    const span = document.createElement("span");
14
    span.setAttribute("role", "img");
15
    span.className = this.classValue;
16
    span.textContent = this.initialsValue;
17
    if (this.element.title) span.title = this.element.title;
18

  
19
    this.element.replaceWith(span);
20
  }
21
}
config/locales/ar.yml
1587 1587
  setting_avatar_enabled: Allow users to set their avatar
1588 1588
  button_change_avatar: Change avatar
1589 1589
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1590
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1591
    with the user's email address is currently used as the avatar. It can be changed
1592
    on that site.
1590
  text_avatar_from_server_html: The image associated with the user's email address on
1591
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1592
    that site. If no image is registered there, a default avatar is shown.
1593 1593
  text_avatar_initials: The image generated from the user's name is currently used as
1594 1594
    the avatar.
1595 1595
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/az.yml
1670 1670
  setting_avatar_enabled: Allow users to set their avatar
1671 1671
  button_change_avatar: Change avatar
1672 1672
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1673
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1674
    with the user's email address is currently used as the avatar. It can be changed
1675
    on that site.
1673
  text_avatar_from_server_html: The image associated with the user's email address on
1674
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1675
    that site. If no image is registered there, a default avatar is shown.
1676 1676
  text_avatar_initials: The image generated from the user's name is currently used as
1677 1677
    the avatar.
1678 1678
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/bg.yml
1525 1525
  setting_avatar_enabled: Allow users to set their avatar
1526 1526
  button_change_avatar: Change avatar
1527 1527
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1528
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1529
    with the user's email address is currently used as the avatar. It can be changed
1530
    on that site.
1528
  text_avatar_from_server_html: The image associated with the user's email address on
1529
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1530
    that site. If no image is registered there, a default avatar is shown.
1531 1531
  text_avatar_initials: The image generated from the user's name is currently used as
1532 1532
    the avatar.
1533 1533
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/bs.yml
1573 1573
  setting_avatar_enabled: Allow users to set their avatar
1574 1574
  button_change_avatar: Change avatar
1575 1575
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1576
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1577
    with the user's email address is currently used as the avatar. It can be changed
1578
    on that site.
1576
  text_avatar_from_server_html: The image associated with the user's email address on
1577
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1578
    that site. If no image is registered there, a default avatar is shown.
1579 1579
  text_avatar_initials: The image generated from the user's name is currently used as
1580 1580
    the avatar.
1581 1581
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/ca.yml
1574 1574
  setting_avatar_enabled: Allow users to set their avatar
1575 1575
  button_change_avatar: Change avatar
1576 1576
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1577
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1578
    with the user's email address is currently used as the avatar. It can be changed
1579
    on that site.
1577
  text_avatar_from_server_html: The image associated with the user's email address on
1578
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1579
    that site. If no image is registered there, a default avatar is shown.
1580 1580
  text_avatar_initials: The image generated from the user's name is currently used as
1581 1581
    the avatar.
1582 1582
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/cs.yml
1567 1567
  setting_avatar_enabled: Allow users to set their avatar
1568 1568
  button_change_avatar: Change avatar
1569 1569
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1570
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1571
    with the user's email address is currently used as the avatar. It can be changed
1572
    on that site.
1570
  text_avatar_from_server_html: The image associated with the user's email address on
1571
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1572
    that site. If no image is registered there, a default avatar is shown.
1573 1573
  text_avatar_initials: The image generated from the user's name is currently used as
1574 1574
    the avatar.
1575 1575
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/da.yml
1604 1604
  setting_avatar_enabled: Allow users to set their avatar
1605 1605
  button_change_avatar: Change avatar
1606 1606
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1607
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1608
    with the user's email address is currently used as the avatar. It can be changed
1609
    on that site.
1607
  text_avatar_from_server_html: The image associated with the user's email address on
1608
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1609
    that site. If no image is registered there, a default avatar is shown.
1610 1610
  text_avatar_initials: The image generated from the user's name is currently used as
1611 1611
    the avatar.
1612 1612
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/de.yml
1543 1543
  setting_avatar_enabled: Allow users to set their avatar
1544 1544
  button_change_avatar: Change avatar
1545 1545
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1546
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1547
    with the user's email address is currently used as the avatar. It can be changed
1548
    on that site.
1546
  text_avatar_from_server_html: The image associated with the user's email address on
1547
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1548
    that site. If no image is registered there, a default avatar is shown.
1549 1549
  text_avatar_initials: The image generated from the user's name is currently used as
1550 1550
    the avatar.
1551 1551
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/el.yml
1587 1587
  setting_avatar_enabled: Allow users to set their avatar
1588 1588
  button_change_avatar: Change avatar
1589 1589
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1590
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1591
    with the user's email address is currently used as the avatar. It can be changed
1592
    on that site.
1590
  text_avatar_from_server_html: The image associated with the user's email address on
1591
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1592
    that site. If no image is registered there, a default avatar is shown.
1593 1593
  text_avatar_initials: The image generated from the user's name is currently used as
1594 1594
    the avatar.
1595 1595
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/en-GB.yml
1588 1588
  setting_avatar_enabled: Allow users to set their avatar
1589 1589
  button_change_avatar: Change avatar
1590 1590
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1591
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1592
    with the user's email address is currently used as the avatar. It can be changed
1593
    on that site.
1591
  text_avatar_from_server_html: The image associated with the user's email address on
1592
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1593
    that site. If no image is registered there, a default avatar is shown.
1594 1594
  text_avatar_initials: The image generated from the user's name is currently used as
1595 1595
    the avatar.
1596 1596
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/en.yml
1400 1400
  text_select_apply_issue_status: "Select issue status"
1401 1401
  text_avatar_server_config_html: The current avatar server is <a href="%{url}">%{url}</a>. You can configure it in config/configuration.yml.
1402 1402
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1403
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated with the user's email address is currently used as the avatar. It can be changed on that site.
1403
  text_avatar_from_server_html: The image associated with the user's email address on <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on that site. If no image is registered there, a default avatar is shown.
1404 1404
  text_avatar_initials: The image generated from the user's name is currently used as the avatar.
1405 1405
  text_avatar_upload_instead: You can upload an image to use instead.
1406 1406
  text_avatar_upload_disabled: Uploading an avatar image to Redmine has been disabled by the administrator.
config/locales/es-PA.yml
1618 1618
  setting_avatar_enabled: Allow users to set their avatar
1619 1619
  button_change_avatar: Change avatar
1620 1620
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1621
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1622
    with the user's email address is currently used as the avatar. It can be changed
1623
    on that site.
1621
  text_avatar_from_server_html: The image associated with the user's email address on
1622
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1623
    that site. If no image is registered there, a default avatar is shown.
1624 1624
  text_avatar_initials: The image generated from the user's name is currently used as
1625 1625
    the avatar.
1626 1626
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/es.yml
1654 1654
  setting_avatar_enabled: Allow users to set their avatar
1655 1655
  button_change_avatar: Change avatar
1656 1656
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1657
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1658
    with the user's email address is currently used as the avatar. It can be changed
1659
    on that site.
1657
  text_avatar_from_server_html: The image associated with the user's email address on
1658
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1659
    that site. If no image is registered there, a default avatar is shown.
1660 1660
  text_avatar_initials: The image generated from the user's name is currently used as
1661 1661
    the avatar.
1662 1662
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/et.yml
1592 1592
  setting_avatar_enabled: Allow users to set their avatar
1593 1593
  button_change_avatar: Change avatar
1594 1594
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1595
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1596
    with the user's email address is currently used as the avatar. It can be changed
1597
    on that site.
1595
  text_avatar_from_server_html: The image associated with the user's email address on
1596
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1597
    that site. If no image is registered there, a default avatar is shown.
1598 1598
  text_avatar_initials: The image generated from the user's name is currently used as
1599 1599
    the avatar.
1600 1600
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/eu.yml
1588 1588
  setting_avatar_enabled: Allow users to set their avatar
1589 1589
  button_change_avatar: Change avatar
1590 1590
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1591
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1592
    with the user's email address is currently used as the avatar. It can be changed
1593
    on that site.
1591
  text_avatar_from_server_html: The image associated with the user's email address on
1592
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1593
    that site. If no image is registered there, a default avatar is shown.
1594 1594
  text_avatar_initials: The image generated from the user's name is currently used as
1595 1595
    the avatar.
1596 1596
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/fa.yml
1516 1516
  setting_avatar_enabled: Allow users to set their avatar
1517 1517
  button_change_avatar: Change avatar
1518 1518
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1519
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1520
    with the user's email address is currently used as the avatar. It can be changed
1521
    on that site.
1519
  text_avatar_from_server_html: The image associated with the user's email address on
1520
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1521
    that site. If no image is registered there, a default avatar is shown.
1522 1522
  text_avatar_initials: The image generated from the user's name is currently used as
1523 1523
    the avatar.
1524 1524
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/fi.yml
1605 1605
  setting_avatar_enabled: Allow users to set their avatar
1606 1606
  button_change_avatar: Change avatar
1607 1607
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1608
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1609
    with the user's email address is currently used as the avatar. It can be changed
1610
    on that site.
1608
  text_avatar_from_server_html: The image associated with the user's email address on
1609
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1610
    that site. If no image is registered there, a default avatar is shown.
1611 1611
  text_avatar_initials: The image generated from the user's name is currently used as
1612 1612
    the avatar.
1613 1613
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/fr.yml
1553 1553
  setting_avatar_enabled: Allow users to set their avatar
1554 1554
  button_change_avatar: Change avatar
1555 1555
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1556
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1557
    with the user's email address is currently used as the avatar. It can be changed
1558
    on that site.
1556
  text_avatar_from_server_html: The image associated with the user's email address on
1557
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1558
    that site. If no image is registered there, a default avatar is shown.
1559 1559
  text_avatar_initials: The image generated from the user's name is currently used as
1560 1560
    the avatar.
1561 1561
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/gl.yml
1594 1594
  setting_avatar_enabled: Allow users to set their avatar
1595 1595
  button_change_avatar: Change avatar
1596 1596
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1597
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1598
    with the user's email address is currently used as the avatar. It can be changed
1599
    on that site.
1597
  text_avatar_from_server_html: The image associated with the user's email address on
1598
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1599
    that site. If no image is registered there, a default avatar is shown.
1600 1600
  text_avatar_initials: The image generated from the user's name is currently used as
1601 1601
    the avatar.
1602 1602
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/he.yml
1592 1592
  setting_avatar_enabled: Allow users to set their avatar
1593 1593
  button_change_avatar: Change avatar
1594 1594
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1595
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1596
    with the user's email address is currently used as the avatar. It can be changed
1597
    on that site.
1595
  text_avatar_from_server_html: The image associated with the user's email address on
1596
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1597
    that site. If no image is registered there, a default avatar is shown.
1598 1598
  text_avatar_initials: The image generated from the user's name is currently used as
1599 1599
    the avatar.
1600 1600
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/hr.yml
1584 1584
  setting_avatar_enabled: Allow users to set their avatar
1585 1585
  button_change_avatar: Change avatar
1586 1586
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1587
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1588
    with the user's email address is currently used as the avatar. It can be changed
1589
    on that site.
1587
  text_avatar_from_server_html: The image associated with the user's email address on
1588
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1589
    that site. If no image is registered there, a default avatar is shown.
1590 1590
  text_avatar_initials: The image generated from the user's name is currently used as
1591 1591
    the avatar.
1592 1592
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/hu.yml
1522 1522
  setting_avatar_enabled: Allow users to set their avatar
1523 1523
  button_change_avatar: Change avatar
1524 1524
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1525
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1526
    with the user's email address is currently used as the avatar. It can be changed
1527
    on that site.
1525
  text_avatar_from_server_html: The image associated with the user's email address on
1526
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1527
    that site. If no image is registered there, a default avatar is shown.
1528 1528
  text_avatar_initials: The image generated from the user's name is currently used as
1529 1529
    the avatar.
1530 1530
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/id.yml
1589 1589
  setting_avatar_enabled: Allow users to set their avatar
1590 1590
  button_change_avatar: Change avatar
1591 1591
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1592
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1593
    with the user's email address is currently used as the avatar. It can be changed
1594
    on that site.
1592
  text_avatar_from_server_html: The image associated with the user's email address on
1593
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1594
    that site. If no image is registered there, a default avatar is shown.
1595 1595
  text_avatar_initials: The image generated from the user's name is currently used as
1596 1596
    the avatar.
1597 1597
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/it.yml
1413 1413
  text_select_apply_issue_status: "Seleziona lo stato della segnalazione"
1414 1414
  text_avatar_server_config_html: "Il server corrente degli avatar è <a href=\"%{url}\">%{url}</a>. È possibile configurarlo in config/configuration.yml."
1415 1415
  text_avatar_uploaded: L'immagine caricata è attualmente usata come avatar.
1416
  text_avatar_from_server_html: L'immagine di <a href="%{url}">%{url}</a> associata all'indirizzo email dell'utente è attualmente usata come avatar. Può essere modificata su quel sito.
1416
  text_avatar_from_server_html: The image associated with the user's email address on <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on that site. If no image is registered there, a default avatar is shown.
1417 1417
  text_avatar_initials: L'immagine generata dal nome dell'utente è attualmente usata come avatar.
1418 1418
  text_avatar_upload_instead: Puoi invece caricare un'immagine da usare.
1419 1419
  text_avatar_upload_disabled: Il caricamento di un'immagine avatar su Redmine è stato disabilitato dall'amministratore.
config/locales/ja.yml
1526 1526
  setting_avatar_enabled: ユーザーによるアバターの設定を許可
1527 1527
  button_change_avatar: アバター変更
1528 1528
  text_avatar_uploaded: 現在はアップロードされた画像がアバターとして使用されています。
1529
  text_avatar_from_server_html: 現在は <a href="%{url}">%{url}</a> でユーザーのメールアドレスに関連づけられている画像がアバターとして使用されています。変更はそのサイトで行えます。
1529
  text_avatar_from_server_html: The image associated with the user's email address on
1530
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1531
    that site. If no image is registered there, a default avatar is shown.
1530 1532
  text_avatar_initials: 現在はユーザーの名前から生成された画像がアバターとして使用されています。
1531 1533
  text_avatar_upload_instead: 代わりに使用する画像をアップロードすることもできます。
1532 1534
  text_avatar_upload_disabled: アバター画像のアップロードは管理者によって無効にされています。
config/locales/ko.yml
1604 1604
  setting_avatar_enabled: Allow users to set their avatar
1605 1605
  button_change_avatar: Change avatar
1606 1606
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1607
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1608
    with the user's email address is currently used as the avatar. It can be changed
1609
    on that site.
1607
  text_avatar_from_server_html: The image associated with the user's email address on
1608
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1609
    that site. If no image is registered there, a default avatar is shown.
1610 1610
  text_avatar_initials: The image generated from the user's name is currently used as
1611 1611
    the avatar.
1612 1612
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/lt.yml
1548 1548
  setting_avatar_enabled: Allow users to set their avatar
1549 1549
  button_change_avatar: Change avatar
1550 1550
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1551
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1552
    with the user's email address is currently used as the avatar. It can be changed
1553
    on that site.
1551
  text_avatar_from_server_html: The image associated with the user's email address on
1552
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1553
    that site. If no image is registered there, a default avatar is shown.
1554 1554
  text_avatar_initials: The image generated from the user's name is currently used as
1555 1555
    the avatar.
1556 1556
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/lv.yml
1581 1581
  setting_avatar_enabled: Allow users to set their avatar
1582 1582
  button_change_avatar: Change avatar
1583 1583
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1584
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1585
    with the user's email address is currently used as the avatar. It can be changed
1586
    on that site.
1584
  text_avatar_from_server_html: The image associated with the user's email address on
1585
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1586
    that site. If no image is registered there, a default avatar is shown.
1587 1587
  text_avatar_initials: The image generated from the user's name is currently used as
1588 1588
    the avatar.
1589 1589
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/mk.yml
1587 1587
  setting_avatar_enabled: Allow users to set their avatar
1588 1588
  button_change_avatar: Change avatar
1589 1589
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1590
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1591
    with the user's email address is currently used as the avatar. It can be changed
1592
    on that site.
1590
  text_avatar_from_server_html: The image associated with the user's email address on
1591
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1592
    that site. If no image is registered there, a default avatar is shown.
1593 1593
  text_avatar_initials: The image generated from the user's name is currently used as
1594 1594
    the avatar.
1595 1595
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/mn.yml
1587 1587
  setting_avatar_enabled: Allow users to set their avatar
1588 1588
  button_change_avatar: Change avatar
1589 1589
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1590
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1591
    with the user's email address is currently used as the avatar. It can be changed
1592
    on that site.
1590
  text_avatar_from_server_html: The image associated with the user's email address on
1591
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1592
    that site. If no image is registered there, a default avatar is shown.
1593 1593
  text_avatar_initials: The image generated from the user's name is currently used as
1594 1594
    the avatar.
1595 1595
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/nl.yml
1562 1562
  setting_avatar_enabled: Allow users to set their avatar
1563 1563
  button_change_avatar: Change avatar
1564 1564
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1565
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1566
    with the user's email address is currently used as the avatar. It can be changed
1567
    on that site.
1565
  text_avatar_from_server_html: The image associated with the user's email address on
1566
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1567
    that site. If no image is registered there, a default avatar is shown.
1568 1568
  text_avatar_initials: The image generated from the user's name is currently used as
1569 1569
    the avatar.
1570 1570
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/no.yml
1578 1578
  setting_avatar_enabled: Allow users to set their avatar
1579 1579
  button_change_avatar: Change avatar
1580 1580
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1581
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1582
    with the user's email address is currently used as the avatar. It can be changed
1583
    on that site.
1581
  text_avatar_from_server_html: The image associated with the user's email address on
1582
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1583
    that site. If no image is registered there, a default avatar is shown.
1584 1584
  text_avatar_initials: The image generated from the user's name is currently used as
1585 1585
    the avatar.
1586 1586
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/pl.yml
1531 1531
  setting_avatar_enabled: Allow users to set their avatar
1532 1532
  button_change_avatar: Change avatar
1533 1533
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1534
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1535
    with the user's email address is currently used as the avatar. It can be changed
1536
    on that site.
1534
  text_avatar_from_server_html: The image associated with the user's email address on
1535
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1536
    that site. If no image is registered there, a default avatar is shown.
1537 1537
  text_avatar_initials: The image generated from the user's name is currently used as
1538 1538
    the avatar.
1539 1539
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/pt-BR.yml
1592 1592
  setting_avatar_enabled: Allow users to set their avatar
1593 1593
  button_change_avatar: Change avatar
1594 1594
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1595
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1596
    with the user's email address is currently used as the avatar. It can be changed
1597
    on that site.
1595
  text_avatar_from_server_html: The image associated with the user's email address on
1596
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1597
    that site. If no image is registered there, a default avatar is shown.
1598 1598
  text_avatar_initials: The image generated from the user's name is currently used as
1599 1599
    the avatar.
1600 1600
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/pt.yml
1580 1580
  setting_avatar_enabled: Allow users to set their avatar
1581 1581
  button_change_avatar: Change avatar
1582 1582
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1583
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1584
    with the user's email address is currently used as the avatar. It can be changed
1585
    on that site.
1583
  text_avatar_from_server_html: The image associated with the user's email address on
1584
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1585
    that site. If no image is registered there, a default avatar is shown.
1586 1586
  text_avatar_initials: The image generated from the user's name is currently used as
1587 1587
    the avatar.
1588 1588
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/ro.yml
1582 1582
  setting_avatar_enabled: Allow users to set their avatar
1583 1583
  button_change_avatar: Change avatar
1584 1584
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1585
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1586
    with the user's email address is currently used as the avatar. It can be changed
1587
    on that site.
1585
  text_avatar_from_server_html: The image associated with the user's email address on
1586
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1587
    that site. If no image is registered there, a default avatar is shown.
1588 1588
  text_avatar_initials: The image generated from the user's name is currently used as
1589 1589
    the avatar.
1590 1590
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/ru.yml
1646 1646
  setting_avatar_enabled: Allow users to set their avatar
1647 1647
  button_change_avatar: Change avatar
1648 1648
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1649
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1650
    with the user's email address is currently used as the avatar. It can be changed
1651
    on that site.
1649
  text_avatar_from_server_html: The image associated with the user's email address on
1650
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1651
    that site. If no image is registered there, a default avatar is shown.
1652 1652
  text_avatar_initials: The image generated from the user's name is currently used as
1653 1653
    the avatar.
1654 1654
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/sk.yml
1576 1576
  setting_avatar_enabled: Allow users to set their avatar
1577 1577
  button_change_avatar: Change avatar
1578 1578
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1579
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1580
    with the user's email address is currently used as the avatar. It can be changed
1581
    on that site.
1579
  text_avatar_from_server_html: The image associated with the user's email address on
1580
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1581
    that site. If no image is registered there, a default avatar is shown.
1582 1582
  text_avatar_initials: The image generated from the user's name is currently used as
1583 1583
    the avatar.
1584 1584
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/sl.yml
1587 1587
  setting_avatar_enabled: Allow users to set their avatar
1588 1588
  button_change_avatar: Change avatar
1589 1589
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1590
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1591
    with the user's email address is currently used as the avatar. It can be changed
1592
    on that site.
1590
  text_avatar_from_server_html: The image associated with the user's email address on
1591
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1592
    that site. If no image is registered there, a default avatar is shown.
1593 1593
  text_avatar_initials: The image generated from the user's name is currently used as
1594 1594
    the avatar.
1595 1595
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/sq.yml
1549 1549
  setting_avatar_enabled: Allow users to set their avatar
1550 1550
  button_change_avatar: Change avatar
1551 1551
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1552
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1553
    with the user's email address is currently used as the avatar. It can be changed
1554
    on that site.
1552
  text_avatar_from_server_html: The image associated with the user's email address on
1553
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1554
    that site. If no image is registered there, a default avatar is shown.
1555 1555
  text_avatar_initials: The image generated from the user's name is currently used as
1556 1556
    the avatar.
1557 1557
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/sr-YU.yml
1589 1589
  setting_avatar_enabled: Allow users to set their avatar
1590 1590
  button_change_avatar: Change avatar
1591 1591
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1592
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1593
    with the user's email address is currently used as the avatar. It can be changed
1594
    on that site.
1592
  text_avatar_from_server_html: The image associated with the user's email address on
1593
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1594
    that site. If no image is registered there, a default avatar is shown.
1595 1595
  text_avatar_initials: The image generated from the user's name is currently used as
1596 1596
    the avatar.
1597 1597
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/sr.yml
1588 1588
  setting_avatar_enabled: Allow users to set their avatar
1589 1589
  button_change_avatar: Change avatar
1590 1590
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1591
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1592
    with the user's email address is currently used as the avatar. It can be changed
1593
    on that site.
1591
  text_avatar_from_server_html: The image associated with the user's email address on
1592
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1593
    that site. If no image is registered there, a default avatar is shown.
1594 1594
  text_avatar_initials: The image generated from the user's name is currently used as
1595 1595
    the avatar.
1596 1596
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/sv.yml
1545 1545
  setting_avatar_enabled: Tillåt användare att välja sin avatar
1546 1546
  button_change_avatar: Ändra avatar
1547 1547
  text_avatar_uploaded: Den uppladdade bilden används just nu som avatar.
1548
  text_avatar_from_server_html: 'Bilden från <a href="%{url}">%{url}</a> som hör till användarens e-postadress används just nu som avatar. Den kan bara ändras på den webbplatsen.'
1548
  text_avatar_from_server_html: The image associated with the user's email address on
1549
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1550
    that site. If no image is registered there, a default avatar is shown.
1549 1551
  text_avatar_initials: Bilden som skapats av användarens namn används just nu som avatar.
1550 1552
  text_avatar_upload_instead: Du kan ladda upp en bild att användas i stället.
1551 1553
  text_avatar_upload_disabled: Administratören har stängt av uppladdning av avatarbilder till Redmine.
config/locales/ta-IN.yml
1542 1542
  setting_avatar_enabled: Allow users to set their avatar
1543 1543
  button_change_avatar: Change avatar
1544 1544
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1545
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1546
    with the user's email address is currently used as the avatar. It can be changed
1547
    on that site.
1545
  text_avatar_from_server_html: The image associated with the user's email address on
1546
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1547
    that site. If no image is registered there, a default avatar is shown.
1548 1548
  text_avatar_initials: The image generated from the user's name is currently used as
1549 1549
    the avatar.
1550 1550
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/th.yml
1583 1583
  setting_avatar_enabled: Allow users to set their avatar
1584 1584
  button_change_avatar: Change avatar
1585 1585
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1586
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1587
    with the user's email address is currently used as the avatar. It can be changed
1588
    on that site.
1586
  text_avatar_from_server_html: The image associated with the user's email address on
1587
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1588
    that site. If no image is registered there, a default avatar is shown.
1589 1589
  text_avatar_initials: The image generated from the user's name is currently used as
1590 1590
    the avatar.
1591 1591
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/tr.yml
1586 1586
  setting_avatar_enabled: Allow users to set their avatar
1587 1587
  button_change_avatar: Change avatar
1588 1588
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1589
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1590
    with the user's email address is currently used as the avatar. It can be changed
1591
    on that site.
1589
  text_avatar_from_server_html: The image associated with the user's email address on
1590
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1591
    that site. If no image is registered there, a default avatar is shown.
1592 1592
  text_avatar_initials: The image generated from the user's name is currently used as
1593 1593
    the avatar.
1594 1594
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/uk.yml
1575 1575
  setting_avatar_enabled: Allow users to set their avatar
1576 1576
  button_change_avatar: Change avatar
1577 1577
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1578
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1579
    with the user's email address is currently used as the avatar. It can be changed
1580
    on that site.
1578
  text_avatar_from_server_html: The image associated with the user's email address on
1579
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1580
    that site. If no image is registered there, a default avatar is shown.
1581 1581
  text_avatar_initials: The image generated from the user's name is currently used as
1582 1582
    the avatar.
1583 1583
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/vi.yml
1591 1591
  setting_avatar_enabled: Allow users to set their avatar
1592 1592
  button_change_avatar: Change avatar
1593 1593
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1594
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1595
    with the user's email address is currently used as the avatar. It can be changed
1596
    on that site.
1594
  text_avatar_from_server_html: The image associated with the user's email address on
1595
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1596
    that site. If no image is registered there, a default avatar is shown.
1597 1597
  text_avatar_initials: The image generated from the user's name is currently used as
1598 1598
    the avatar.
1599 1599
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/zh-TW.yml
1598 1598
  setting_avatar_enabled: Allow users to set their avatar
1599 1599
  button_change_avatar: Change avatar
1600 1600
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1601
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1602
    with the user's email address is currently used as the avatar. It can be changed
1603
    on that site.
1601
  text_avatar_from_server_html: The image associated with the user's email address on
1602
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1603
    that site. If no image is registered there, a default avatar is shown.
1604 1604
  text_avatar_initials: The image generated from the user's name is currently used as
1605 1605
    the avatar.
1606 1606
  text_avatar_upload_instead: You can upload an image to use instead.
config/locales/zh.yml
1523 1523
  setting_avatar_enabled: Allow users to set their avatar
1524 1524
  button_change_avatar: Change avatar
1525 1525
  text_avatar_uploaded: The uploaded image is currently used as the avatar.
1526
  text_avatar_from_server_html: The image from <a href="%{url}">%{url}</a> associated
1527
    with the user's email address is currently used as the avatar. It can be changed
1528
    on that site.
1526
  text_avatar_from_server_html: The image associated with the user's email address on
1527
    <a href="%{url}">%{url}</a> is currently used as the avatar. It can be changed on
1528
    that site. If no image is registered there, a default avatar is shown.
1529 1529
  text_avatar_initials: The image generated from the user's name is currently used as
1530 1530
    the avatar.
1531 1531
  text_avatar_upload_instead: You can upload an image to use instead.
test/helpers/avatars_helper_test.rb
53 53
  def test_avatar_source_info
54 54
    Redmine::Thumbnail.stubs(:convert_available?).returns(true)
55 55
    user = User.find(2)
56
    assert_include 'It can be changed on that site. You can upload an image to use instead.', avatar_source_info(user)
56
    assert_include 'a default avatar is shown. You can upload an image to use instead.', avatar_source_info(user)
57 57
    with_settings :gravatar_enabled => '0' do
58 58
      assert_include 'generated from the user', avatar_source_info(user)
59 59
    end
......
120 120
    end
121 121
  end
122 122

  
123
  def test_avatar_without_default_should_fall_back_to_initials_avatar
124
    with_settings :gravatar_default => '' do
125
      avatar_tag = avatar(User.find_by_mail('jsmith@somenet.foo'))
126

  
127
      assert_include 'default=404', avatar_tag
128
      assert_select_in avatar_tag, 'img[data-controller="initials-avatar-fallback"]' \
129
                                   '[data-initials-avatar-fallback-initials-value="JS"]' \
130
                                   '[data-initials-avatar-fallback-class-value="avatar-color-2 s24 avatar active"]'
131
    end
132
  end
133

  
134
  def test_avatar_with_default_should_not_fall_back_to_initials_avatar
135
    with_settings :gravatar_default => 'identicon' do
136
      avatar_tag = avatar(User.find_by_mail('jsmith@somenet.foo'))
137

  
138
      assert_include 'default=identicon', avatar_tag
139
      assert_not_include 'initials-avatar-fallback', avatar_tag
140
    end
141
  end
142

  
123 143
  def test_avatar_disabled_should_display_user_initials
124 144
    with_settings :gravatar_enabled => '0' do
125 145
      assert_equal "<span role=\"img\" class=\"avatar-color-2 s24 avatar active\">JS</span>", avatar(User.find_by_mail('jsmith@somenet.foo'))
test/system/avatars_test.rb
1
# frozen_string_literal: true
2

  
3
# Redmine - project management software
4
# Copyright (C) 2006-  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
require_relative '../application_system_test_case'
21

  
22
class AvatarsTest < ApplicationSystemTestCase
23
  def test_gravatar_without_default_should_fall_back_to_initials_avatar_if_not_found
24
    with_settings :gravatar_enabled => '1', :gravatar_default => '' do
25
      # Requests to /avatar/:hash on Redmine itself respond with 404
26
      Redmine::Configuration.with 'avatar_server_url' => '' do
27
        log_user('jsmith', 'jsmith')
28
        visit '/users/2'
29

  
30
        assert_selector 'h2 span[role="img"].avatar.avatar-color-2.s50.active', :text => 'JS'
31
        assert_no_selector 'h2 img.gravatar'
32
      end
33
    end
34
  end
35
end
(6-6/8)