MDL-70829 core: Remove presentation role for decorative images

* An image with non-empty alt text should not have a presentation role.
* An empty alt attribute is sufficient for decorative images. No need to
add a presentation role for them.
* Additionally, if there is already text that is present for an image,
there's no need to add an alt text with the same text. Such images are
decorative and should just have an empty alt text.
This commit is contained in:
Jun Pataleta 2024-03-18 19:50:19 +08:00
parent b621a7e4b3
commit 5289581d06
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
3 changed files with 6 additions and 7 deletions

View File

@ -11067,7 +11067,7 @@ class admin_setting_php_extension_enabled extends admin_setting {
$o = '';
if (!extension_loaded($this->extension)) {
$warning = $OUTPUT->pix_icon('i/warning', '', '', array('role' => 'presentation')) . ' ' . $this->description;
$warning = $OUTPUT->pix_icon('i/warning', '') . ' ' . $this->description;
$o .= format_admin_setting($this, $this->visiblename, $warning);
}

View File

@ -2362,7 +2362,7 @@ class core_renderer extends renderer_base {
public function doc_link($path, $text = '', $forcepopup = false, array $attributes = []) {
global $CFG;
$icon = $this->pix_icon('book', '', 'moodle', array('class' => 'iconhelp icon-pre', 'role' => 'presentation'));
$icon = $this->pix_icon('book', '', 'moodle', array('class' => 'iconhelp icon-pre'));
$attributes['href'] = new moodle_url(get_docs_url($path));
$newwindowicon = '';
@ -4656,15 +4656,14 @@ EOD;
if ($button['buttontype'] === 'message') {
\core_message\helper::messageuser_requirejs();
}
$image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
$image = $this->pix_icon($button['formattedimage'], '', 'moodle', array(
'class' => 'iconsmall',
'role' => 'presentation'
));
$image .= html_writer::span($button['title'], 'header-button-title');
} else {
$image = html_writer::empty_tag('img', array(
'src' => $button['formattedimage'],
'role' => 'presentation'
'alt' => $button['title'],
));
}
$html .= html_writer::link($button['url'], html_writer::tag('span', $image), $button['linkattributes']);

View File

@ -1095,9 +1095,9 @@ EXPECTED;
$url1 = "{$CFG->wwwroot}/draftfile.php/5/user/draft/99999999/test1.jpg";
$url2 = "{$CFG->wwwroot}/draftfile.php/5/user/draft/99999998/test2.jpg";
$html = "<p>This is a test.</p><p><img src=\"{$url1}\" alt=\"\" role=\"presentation\"></p>
$html = "<p>This is a test.</p><p><img src=\"{$url1}\" alt=\"\"></p>
<br>Test content.<p></p><p><img src=\"{$url2}\" alt=\"\" width=\"2048\" height=\"1536\"
role=\"presentation\" class=\"img-fluid atto_image_button_text-bottom\"><br></p>";
class=\"img-fluid atto_image_button_text-bottom\"><br></p>";
$draftareas = array(
array(
'urlbase' => 'draftfile.php',