From 700bcb30b01301e9fb804ef1b1f13cbadcb44911 Mon Sep 17 00:00:00 2001 From: Remember the dot Date: Wed, 15 Jul 2009 04:18:16 +0000 Subject: [PATCH] Applied image attribute improvements from r52726 to galleries as well --- includes/ImageGallery.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 3228b5901a..987d76ad1c 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -236,7 +236,7 @@ class ImageGallery $i = 0; foreach ( $this->mImages as $pair ) { $nt = $pair[0]; - $text = $pair[1]; + $text = $pair[1]; # "text" means "caption" here # Give extensions a chance to select the file revision for us $time = $descQuery = false; @@ -265,6 +265,15 @@ class ImageGallery . htmlspecialchars( $img->getLastError() ) . ''; } else { $vpad = floor( ( 1.25*$this->mHeights - $thumb->height ) /2 ) - 2; + + $imageParameters = array( + 'desc-link' => true, + 'desc-query' => $descQuery + ); + # In the absence of a caption, fall back on providing screen readers with the filename as alt text + if ( $text == '' ) { + $imageParameters['alt'] = $nt->getText(); + } $thumbhtml = "\n\t\t\t". '
' @@ -272,7 +281,7 @@ class ImageGallery # handlers since they may emit block-level elements as opposed to simple tags. # ref http://css-discuss.incutio.com/?page=CenteringBlockElement . '
' - . $thumb->toHtml( array( 'desc-link' => true, 'desc-query' => $descQuery ) ) . '
'; + . $thumb->toHtml( $imageParameters ) . ''; // Call parser transform hook if ( $this->mParser && $img->getHandler() ) { -- 2.20.1