Add aria-label to letter avatars

This commit is contained in:
Michael Vickers
2020-10-03 12:05:31 +01:00
committed by Frédéric Guillot
parent 6231c159b8
commit 33531d47c2
3 changed files with 8 additions and 6 deletions

View File

@@ -32,13 +32,15 @@ class LetterAvatarProvider extends Base implements AvatarProviderInterface
{
$initials = $this->helper->user->getInitials($user['name'] ?: $user['username']);
$rgb = $this->getBackgroundColor($user['name'] ?: $user['username']);
$name = $this->helper->text->e($user['name'] ?: $user['username']);
return sprintf(
'<div class="avatar-letter" style="background-color: rgb(%d, %d, %d)" title="%s">%s</div>',
'<div class="avatar-letter" style="background-color: rgb(%d, %d, %d)" title="%s" role="img" aria-label="%s">%s</div>',
$rgb[0],
$rgb[1],
$rgb[2],
$this->helper->text->e($user['name'] ?: $user['username']),
$name,
$name,
$this->helper->text->e($initials)
);
}