A11Y: ensures avatar image in site header has alt attribute (#12161)

This commit is contained in:
Joffrey JAFFEUX 2021-02-22 11:09:18 +01:00 committed by GitHub
parent a60e26e799
commit 72258c663b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -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)
)
),
];

View File

@ -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),