/** * * @param File $img * @param Title $nt * @param String $text * @param String $alt * @param Title $titleLink * @param type $descQuery * @return String */ private function photoToHTML($img, $nt, $text = '', $alt = '', $titleLink = null, $descQuery = '') { $params = array('width' => $this->mPhotoWidth, 'height' => $this->mPhotoHeight); if (!$img) { $html = '<div class="CarError" style="height: ' . $params['height'] . 'px; width: ' . $params['width'] . 'px;">' . htmlspecialchars($nt->getText()) . '</div>'; } else { if ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) { $html = '<div class="CarError" style="height: ' . $params['height'] . 'px; width: ' . $params['width'] . 'px;">' . Linker::link($nt, htmlspecialchars($nt->getText()), array(), array(), array('known', 'noclasses')) . '</div>'; } else { if (!($thumb = $img->transform($params))) { # Error generating thumbnail. $html = '<div class="CarError" style="height: ' . $params['height'] . 'px; width: ' . $params['width'] . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>'; } else { $imageParameters = array('desc-link' => true, 'desc-query' => $descQuery, 'alt' => $alt, 'custom-title-link' => $titleLink); # In the absence of both alt text and caption, fall back on providing screen readers with the filename as alt text if ($alt == '') { $imageParameters['alt'] = $nt->getText(); } $html = $thumb->toHtml($imageParameters); // Call parser transform hook if ($this->mParser && $img->getHandler()) { $img->getHandler()->parserTransformHook($this->mParser, $img); } } } } $html .= Html::rawElement('figcaption', array(), $text); $html = Html::rawElement('figure', array(), $html); return $html; }