Index: trunk/phase3/includes/ImageGallery.php |
— | — | @@ -236,7 +236,7 @@ |
237 | 237 | $i = 0; |
238 | 238 | foreach ( $this->mImages as $pair ) { |
239 | 239 | $nt = $pair[0]; |
240 | | - $text = $pair[1]; |
| 240 | + $text = $pair[1]; # "text" means "caption" here |
241 | 241 | |
242 | 242 | # Give extensions a chance to select the file revision for us |
243 | 243 | $time = $descQuery = false; |
— | — | @@ -265,6 +265,15 @@ |
266 | 266 | . htmlspecialchars( $img->getLastError() ) . '</div>'; |
267 | 267 | } else { |
268 | 268 | $vpad = floor( ( 1.25*$this->mHeights - $thumb->height ) /2 ) - 2; |
| 269 | + |
| 270 | + $imageParameters = array( |
| 271 | + 'desc-link' => true, |
| 272 | + 'desc-query' => $descQuery |
| 273 | + ); |
| 274 | + # In the absence of a caption, fall back on providing screen readers with the filename as alt text |
| 275 | + if ( $text == '' ) { |
| 276 | + $imageParameters['alt'] = $nt->getText(); |
| 277 | + } |
269 | 278 | |
270 | 279 | $thumbhtml = "\n\t\t\t". |
271 | 280 | '<div class="thumb" style="padding: ' . $vpad . 'px 0; width: ' .($this->mWidths+30).'px;">' |
— | — | @@ -272,7 +281,7 @@ |
273 | 282 | # handlers since they may emit block-level elements as opposed to simple <img> tags. |
274 | 283 | # ref http://css-discuss.incutio.com/?page=CenteringBlockElement |
275 | 284 | . '<div style="margin-left: auto; margin-right: auto; width: ' .$this->mWidths.'px;">' |
276 | | - . $thumb->toHtml( array( 'desc-link' => true, 'desc-query' => $descQuery ) ) . '</div></div>'; |
| 285 | + . $thumb->toHtml( $imageParameters ) . '</div></div>'; |
277 | 286 | |
278 | 287 | // Call parser transform hook |
279 | 288 | if ( $this->mParser && $img->getHandler() ) { |