mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
A11Y: ensures avatar image in site header has alt attribute (#12161)
This commit is contained in:
parent
a60e26e799
commit
72258c663b
@ -60,7 +60,12 @@ createWidget("header-notifications", {
|
||||
const contents = [
|
||||
avatarImg(
|
||||
this.settings.avatarSize,
|
||||
addExtraUserClasses(user, avatarAttrs)
|
||||
Object.assign(
|
||||
{
|
||||
alt: "user.avatar.header_title",
|
||||
},
|
||||
addExtraUserClasses(user, avatarAttrs)
|
||||
)
|
||||
),
|
||||
];
|
||||
|
||||
|
@ -37,17 +37,21 @@ export function avatarImg(wanted, attrs) {
|
||||
}
|
||||
|
||||
let title;
|
||||
|
||||
if (!attrs.hideTitle) {
|
||||
title = attrs.name || formatUsername(attrs.username);
|
||||
}
|
||||
|
||||
let alt = "";
|
||||
if (attrs.alt) {
|
||||
alt = I18n.t(attrs.alt);
|
||||
}
|
||||
|
||||
let className =
|
||||
"avatar" + (attrs.extraClasses ? " " + attrs.extraClasses : "");
|
||||
|
||||
const properties = {
|
||||
attributes: {
|
||||
alt: "",
|
||||
alt,
|
||||
width: size,
|
||||
height: size,
|
||||
src: getURLWithCDN(url),
|
||||
|
Loading…
Reference in New Issue
Block a user