From 5689bb93e9e73545ede3dd556c5173b96d1d3caf Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 4 Jan 2019 15:49:23 +0800 Subject: [PATCH] MDL-64488 output: User picture Ally Do not include alt and title for a user picture if it is hidden from screen readers. Use aria-hidden to properly hide the image from screen readers. --- lib/outputrenderers.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 6ccfa79d09d..6ef145b5806 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2606,9 +2606,16 @@ class core_renderer extends renderer_base { $src = $userpicture->get_url($this->page, $this); - $attributes = array('src'=>$src, 'alt'=>$alt, 'title'=>$alt, 'class'=>$class, 'width'=>$size, 'height'=>$size); + $attributes = array('src' => $src, 'class' => $class, 'width' => $size, 'height' => $size); if (!$userpicture->visibletoscreenreaders) { $attributes['role'] = 'presentation'; + $alt = ''; + $attributes['aria-hidden'] = 'true'; + } + + if (!empty($alt)) { + $attributes['alt'] = $alt; + $attributes['title'] = $alt; } // get the image html output fisrt