From ca3218b23f6ea6875d8723fd4ad81065da8cd293 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 fe60ba20ed0..09420a39abf 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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); } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 461fae59d76..2f707670adf 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -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']); diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php index f553acaf397..81f83517402 100644 --- a/lib/tests/weblib_test.php +++ b/lib/tests/weblib_test.php @@ -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 = "

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',