From 5289581d06d9b596976984808a4bf805f802d8a5 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 18 Mar 2024 19:50:19 +0800 Subject: [PATCH] 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. --- lib/adminlib.php | 2 +- lib/outputrenderers.php | 7 +++---- lib/tests/weblib_test.php | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/adminlib.php b/lib/adminlib.php index ed0ec215a95..b74788ad339 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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); } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 0fef2261c53..45b2dccd752 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -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']); diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php index 263e5a42005..1ecc422e2c7 100644 --- a/lib/tests/weblib_test.php +++ b/lib/tests/weblib_test.php @@ -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 = "

This is a test.

\"\"

+ $html = "

This is a test.

\"\"


Test content.

\"\"

"; + class=\"img-fluid atto_image_button_text-bottom\">

"; $draftareas = array( array( 'urlbase' => 'draftfile.php',