mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-79059 core: Use full name as alt text for user picture links
When the user picture is being rendered as a link but the user's full name is not being included in the link and the alt text turns out to be empty, we could end up with a link without a discernible text. This is an accessibility issue that will affect screen reader users. If this is the case, use the full name as the user picture's alt text.
This commit is contained in:
parent
f9c46d0026
commit
896d5fd05a
@ -2656,10 +2656,18 @@ class core_renderer extends renderer_base {
|
||||
$alt = '';
|
||||
if ($userpicture->alttext) {
|
||||
if (!empty($user->imagealt)) {
|
||||
$alt = $user->imagealt;
|
||||
$alt = trim($user->imagealt);
|
||||
}
|
||||
}
|
||||
|
||||
// If the user picture is being rendered as a link but without the full name, an empty alt text for the user picture
|
||||
// would mean that the link displayed will not have any discernible text. This becomes an accessibility issue,
|
||||
// especially to screen reader users. Use the user's full name by default for the user picture's alt-text if this is
|
||||
// the case.
|
||||
if ($userpicture->link && !$userpicture->includefullname && empty($alt)) {
|
||||
$alt = fullname($user);
|
||||
}
|
||||
|
||||
if (empty($userpicture->size)) {
|
||||
$size = 35;
|
||||
} else if ($userpicture->size === true or $userpicture->size == 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user