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-04-12 11:13:12 +08:00
parent c9fe574fdd
commit ca3218b23f
3 changed files with 6 additions and 7 deletions
+1 -1
View File
@@ -10993,7 +10993,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);
}
+3 -4
View File
@@ -2327,7 +2327,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 = '';
@@ -4631,15 +4631,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']);
+2 -2
View File
@@ -1186,9 +1186,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',