本文整理汇总了PHP中wfIsBadImage函数的典型用法代码示例。如果您正苦于以下问题:PHP wfIsBadImage函数的具体用法?PHP wfIsBadImage怎么用?PHP wfIsBadImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfIsBadImage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toHTML
function toHTML()
{
global $wgLang;
$sk = $this->getSkin();
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
$i = 0;
$images = array();
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# Give extensions a chance to select the file revision for us
$time = $descQuery = false;
$img = wfFindFile($nt, $time);
if ($nt->getNamespace() != NS_FILE || !$img) {
# We're dealing with a non-image, spit out the name and be done with it.
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
} elseif ($this->mWidths && $this->mHeights && !($thumb = $img->transform($params))) {
# Error generating thumbnail.
} elseif ($img->getMediaType() != 'BITMAP' && $img->getMediaType() != 'DRAWING' && $img->getMediaType() != 'MEDIATYPE_BITMAP' && $img->getMediaType() != 'MEDIATYPE_DRAWING') {
# non image, ignore
} else {
array_push($images, $pair);
}
}
if (count($images) > 0) {
$this->mImages = $images;
$html = ImageGalleryOriginal::toHTML();
// remove links
$trace = debug_backtrace();
$caller = $trace[1];
if ($caller['class'] == 'ParserOriginal' || $caller['class'] == 'Parser') {
preg_match_all('/<a [^>]*>(.*?<img.*?)<\\/a>/s', $html, $matches);
if (count($matches)) {
$html = str_replace($matches[0], $matches[1], $html);
}
}
return $html;
}
return "";
}
示例2: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
* @return string
*/
function toHTML()
{
if ($this->mPerRow > 0) {
$maxwidth = $this->mPerRow * ($this->mWidths + $this->getAllPadding());
$oldStyle = isset($this->mAttribs['style']) ? $this->mAttribs['style'] : '';
# _width is ignored by any sane browser. IE6 doesn't know max-width
# so it uses _width instead
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle;
}
$attribs = Sanitizer::mergeAttributes(['class' => 'gallery mw-gallery-' . $this->mMode], $this->mAttribs);
$modules = $this->getModules();
if ($this->mParser) {
$this->mParser->getOutput()->addModules($modules);
$this->mParser->getOutput()->addModuleStyles('mediawiki.page.gallery.styles');
} else {
$this->getOutput()->addModules($modules);
$this->getOutput()->addModuleStyles('mediawiki.page.gallery.styles');
}
$output = Xml::openElement('ul', $attribs);
if ($this->mCaption) {
$output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
}
if ($this->mShowFilename) {
// Preload LinkCache info for when generating links
// of the filename below
$lb = new LinkBatch();
foreach ($this->mImages as $img) {
$lb->addObj($img[0]);
}
$lb->execute();
}
$lang = $this->getRenderLang();
# Output each image...
foreach ($this->mImages as $pair) {
/** @var Title $nt */
$nt = $pair[0];
$text = $pair[1];
# "text" means "caption" here
$alt = $pair[2];
$link = $pair[3];
$descQuery = false;
if ($nt->getNamespace() === NS_FILE) {
# Get the file...
if ($this->mParser instanceof Parser) {
# Give extensions a chance to select the file revision for us
$options = [];
Hooks::run('BeforeParserFetchFileAndTitle', [$this->mParser, $nt, &$options, &$descQuery]);
# Fetch and register the file (file title may be different via hooks)
list($img, $nt) = $this->mParser->fetchFileAndTitle($nt, $options);
} else {
$img = wfFindFile($nt);
}
} else {
$img = false;
}
$params = $this->getThumbParams($img);
// $pair[4] is per image handler options
$transformOptions = $params + $pair[4];
$thumb = false;
if (!$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ($this->getThumbPadding() + $this->mHeights) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
if ($this->mParser instanceof Parser) {
$this->mParser->addTrackingCategory('broken-file-category');
}
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ($this->getThumbPadding() + $this->mHeights) . 'px;">' . Linker::linkKnown($nt, htmlspecialchars($nt->getText())) . '</div>';
} else {
$thumb = $img->transform($transformOptions);
if (!$thumb) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ($this->getThumbPadding() + $this->mHeights) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
/** @var MediaTransformOutput $thumb */
$vpad = $this->getVPad($this->mHeights, $thumb->getHeight());
$imageParameters = ['desc-link' => true, 'desc-query' => $descQuery, 'alt' => $alt, 'custom-url-link' => $link];
// In the absence of both alt text and caption, fall back on
// providing screen readers with the filename as alt text
if ($alt == '' && $text == '') {
$imageParameters['alt'] = $nt->getText();
}
$this->adjustImageParameters($thumb, $imageParameters);
Linker::processResponsiveImages($img, $thumb, $transformOptions);
# Set both fixed width and min-height.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="width: ' . $this->getThumbDivWidth($thumb->getWidth()) . 'px;">' . '<div style="margin:' . $vpad . 'px auto;">' . $thumb->toHtml($imageParameters) . '</div></div>';
// Call parser transform hook
/** @var MediaHandler $handler */
$handler = $img->getHandler();
//.........这里部分代码省略.........
示例3: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
*/
function toHTML()
{
global $wgLang;
$sk = $this->getSkin();
$attribs = Sanitizer::mergeAttributes(array('class' => 'gallery', 'cellspacing' => '0', 'cellpadding' => '0'), $this->mAttribs);
$s = Xml::openElement('table', $attribs);
if ($this->mCaption) {
$s .= "\n\t<caption>{$this->mCaption}</caption>";
}
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
$i = 0;
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# Give extensions a chance to select the file revision for us
$time = $descQuery = false;
wfRunHooks('BeforeGalleryFindFile', array(&$this, &$nt, &$time, &$descQuery));
$img = wfFindFile($nt, $time);
if ($nt->getNamespace() != NS_FILE || !$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . $sk->makeKnownLinkObj($nt, htmlspecialchars($nt->getText())) . '</div>';
} elseif (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$vpad = floor((1.25 * $this->mHeights - $thumb->height) / 2) - 2;
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="padding: ' . $vpad . 'px 0; width: ' . ($this->mWidths + 30) . 'px;">' . '<div style="margin-left: auto; margin-right: auto; width: ' . $this->mWidths . 'px;">' . $thumb->toHtml(array('desc-link' => true, 'desc-query' => $descQuery)) . '</div></div>';
// Call parser transform hook
if ($this->mParser && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
}
//TODO
//$ul = $sk->makeLink( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}", $ut );
if ($this->mShowBytes) {
if ($img) {
$nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($img->getSize()));
} else {
$nb = wfMsgHtml('filemissing');
}
$nb = "{$nb}<br />\n";
} else {
$nb = '';
}
$textlink = $this->mShowFilename ? $sk->makeKnownLinkObj($nt, htmlspecialchars($wgLang->truncate($nt->getText(), 20, '...'))) . "<br />\n" : '';
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
if ($i % $this->mPerRow == 0) {
$s .= "\n\t<tr>";
}
$s .= "\n\t\t" . '<td><div class="gallerybox" style="width: ' . ($this->mWidths + 35) . 'px;">' . $thumbhtml . "\n\t\t\t" . '<div class="gallerytext">' . "\n" . $textlink . $text . $nb . "\n\t\t\t</div>" . "\n\t\t</div></td>";
if ($i % $this->mPerRow == $this->mPerRow - 1) {
$s .= "\n\t</tr>";
}
++$i;
}
if ($i % $this->mPerRow != 0) {
$s .= "\n\t</tr>";
}
$s .= "\n</table>";
return $s;
}
示例4: replaceInternalLinks2
//.........这里部分代码省略.........
continue;
}
wfProfileOut(__METHOD__ . "-might_be_img");
}
$wasblank = $text == '';
if ($wasblank) {
$text = $link;
} else {
# Bug 4598 madness. Handle the quotes only if they come from the alternate part
# [[Lista d''e paise d''o munno]] -> <a href="...">Lista d''e paise d''o munno</a>
# [[Criticism of Harry Potter|Criticism of ''Harry Potter'']]
# -> <a href="Criticism of Harry Potter">Criticism of <i>Harry Potter</i></a>
$text = $this->doQuotes($text);
}
# Link not escaped by : , create the various objects
if ($noforce) {
# Interwikis
wfProfileIn(__METHOD__ . "-interwiki");
if ($iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName($iw, null, 'mw')) {
// XXX: the above check prevents links to sites with identifiers that are not language codes
# Bug 24502: filter duplicates
if (!isset($this->mLangLinkLanguages[$iw])) {
$this->mLangLinkLanguages[$iw] = true;
$this->mOutput->addLanguageLink($nt->getFullText());
}
$s = rtrim($s . $prefix);
$s .= trim($trail, "\n") == '' ? '' : $prefix . $trail;
wfProfileOut(__METHOD__ . "-interwiki");
continue;
}
wfProfileOut(__METHOD__ . "-interwiki");
if ($ns == NS_FILE) {
wfProfileIn(__METHOD__ . "-image");
if (!wfIsBadImage($nt->getDBkey(), $this->mTitle)) {
if ($wasblank) {
# if no parameters were passed, $text
# becomes something like "File:Foo.png",
# which we don't want to pass on to the
# image generator
$text = '';
} else {
# recursively parse links inside the image caption
# actually, this will parse them in any other parameters, too,
# but it might be hard to fix that, and it doesn't matter ATM
$text = $this->replaceExternalLinks($text);
$holders->merge($this->replaceInternalLinks2($text));
}
# cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
$s .= $prefix . $this->armorLinks($this->makeImage($nt, $text, $holders)) . $trail;
} else {
$s .= $prefix . $trail;
}
wfProfileOut(__METHOD__ . "-image");
continue;
}
if ($ns == NS_CATEGORY) {
wfProfileIn(__METHOD__ . "-category");
$s = rtrim($s . "\n");
# bug 87
if ($wasblank) {
$sortkey = $this->getDefaultSort();
} else {
$sortkey = $text;
}
$sortkey = Sanitizer::decodeCharReferences($sortkey);
$sortkey = str_replace("\n", '', $sortkey);
示例5: toHTML
function toHTML()
{
global $wgLang, $mvDefaultAspectRatio;
$sk = $this->getSkin();
$attribs = Sanitizer::mergeAttributes(array('class' => 'gallery', 'cellspacing' => '0', 'cellpadding' => '0'), $this->mAttribs);
$s = Xml::openElement('table', $attribs);
if ($this->mCaption) {
$s .= "\n\t<caption>" . htmlspecialchars($this->mCaption) . "</caption>";
}
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
$i = 0;
$this->already_named_resource = array();
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# Give extensions a chance to select the file revision for us
$time = false;
wfRunHooks('BeforeGalleryFindFile', array(&$this, &$nt, &$time));
$img = wfFindFile($nt, array('time' => $time));
if ($nt->getNamespace() == MV_NS_MVD || $nt->getNamespace() == MV_NS_STREAM || $nt->getNamespace() == MV_NS_SEQUENCE) {
// @@todo fix sequence embed
// $vpad = floor( ( 1.25*$this->mHeights - $thumb->height ) /2 ) - 2;
$mvTitle = new MV_Title($nt);
// remap MVD namespace links into the Stream view (so contextual metadata is present)
if ($nt->getNamespace() == MV_NS_MVD) {
$nt = Title::MakeTitle(MV_NS_STREAM, ucfirst($mvTitle->getStreamName()) . '/' . $mvTitle->getTimeRequest());
}
$vidH = round($this->mWidths * $mvDefaultAspectRatio);
$vidRes = $this->mWidths . 'x' . $vidH;
// print "img url: " . $mvTitle->getStreamImageURL();
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="padding: 4px 0; width: ' . htmlspecialchars($this->mWidths + 5) . 'px;">' . '<div style="margin-left: auto; margin-right: auto; width: ' . htmlspecialchars($this->mWidths) . 'px;">' . $sk->makeKnownLinkObj($nt, '<img title="' . htmlspecialchars($mvTitle->getStreamNameText()) . '"' . ' width="160" height="120" src="' . $mvTitle->getStreamImageURL('160x120') . '">') . '</div>' . '</div>' . '<span class="gallerytext" style="float:left">' . $sk->makeKnownLinkObj($nt, $mvTitle->getStreamNameText() . ' ' . $mvTitle->getTimeDesc()) . '</span>' . '</div>';
$nb = '';
$textlink = '';
} else {
if ($nt->getNamespace() != NS_IMAGE || !$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . $sk->makeKnownLinkObj($nt, htmlspecialchars($nt->getText())) . '</div>';
} elseif (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$vpad = floor((1.25 * $this->mHeights - $thumb->height) / 2) - 2;
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="padding: ' . htmlspecialchars($vpad) . 'px 0; width: ' . htmlspecialchars($this->mWidths + 30) . 'px;">' . '<div style="margin-left: auto; margin-right: auto; width: ' . htmlspecialchars($this->mWidths) . 'px;">' . $thumb->toHtml(array('desc-link' => true)) . '</div></div>';
// Call parser transform hook
if ($this->mParser && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
}
if ($this->mShowBytes) {
if ($img) {
$nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($img->getSize()));
} else {
$nb = wfMsgHtml('filemissing');
}
$nb = "{$nb}<br />\n";
} else {
$nb = '';
}
$textlink = $this->mShowFilename ? $sk->makeKnownLinkObj($nt, htmlspecialchars($wgLang->truncate($nt->getText(), 20))) . "<br />\n" : '';
}
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
if ($i % $this->mPerRow == 0) {
$s .= "\n\t<tr>";
}
$s .= "\n\t\t" . '<td><div class="gallerybox" style="width: ' . ($this->mWidths + 10) . 'px;">' . $thumbhtml . "\n\t\t\t" . '<div class="gallerytext">' . "\n" . $textlink . htmlspecialchars($text) . $nb . "\n\t\t\t</div>" . "\n\t\t</div></td>";
if ($i % $this->mPerRow == $this->mPerRow - 1) {
$s .= "\n\t</tr>";
}
++$i;
}
if ($i % $this->mPerRow != 0) {
$s .= "\n\t</tr>";
}
$s .= "\n</table>";
return $s;
}
示例6: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
*/
function toHTML()
{
global $wgLang, $wgIgnoreImageErrors, $wgGenerateThumbnailOnParse;
$sk = $this->getSkin();
$s = '<table class="gallery" cellspacing="0" cellpadding="0">';
if ($this->mCaption) {
$s .= '<td class="galleryheader" colspan="4"><big>' . htmlspecialchars($this->mCaption) . '</big></td>';
}
$i = 0;
foreach ($this->mImages as $pair) {
$img =& $pair[0];
$text = $pair[1];
$name = $img->getName();
$nt = $img->getTitle();
if ($nt->getNamespace() != NS_IMAGE) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = '<div style="height: 152px;">' . htmlspecialchars($nt->getText()) . '</div>';
} else {
if ($this->mParsing && wfIsBadImage($nt->getDBkey())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = '<div style="height: 152px;">' . $sk->makeKnownLinkObj($nt, htmlspecialchars($nt->getText())) . '</div>';
} else {
if (!($thumb = $img->getThumbnail(120, 120, $wgGenerateThumbnailOnParse))) {
# Error generating thumbnail.
$thumbhtml = '<div style="height: 152px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$vpad = floor((150 - $thumb->height) / 2) - 2;
$thumbhtml = '<div class="thumb" style="padding: ' . $vpad . 'px 0;">' . $sk->makeKnownLinkObj($nt, $thumb->toHtml()) . '</div>';
}
}
}
//TODO
//$ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
if ($this->mShowBytes) {
if ($img->exists()) {
$nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($img->getSize()));
} else {
$nb = wfMsgHtml('filemissing');
}
$nb = "{$nb}<br />\n";
} else {
$nb = '';
}
$textlink = $this->mShowFilename ? $sk->makeKnownLinkObj($nt, htmlspecialchars($wgLang->truncate($nt->getText(), 20, '...'))) . "<br />\n" : '';
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
$s .= $i % 4 == 0 ? '<tr>' : '';
$s .= '<td><div class="gallerybox">' . $thumbhtml . '<div class="gallerytext">' . "\n" . $textlink . $text . $nb . "</div></div></td>\n";
$s .= $i % 4 == 3 ? '</tr>' : '';
$i++;
}
if ($i % 4 != 0) {
$s .= "</tr>\n";
}
$s .= '</table>';
return $s;
}
示例7: render
static function render($input, $params, $parser)
{
global $wgScriptPath, $wgUser, $wgUrlProtocols, $wgNoFollowLinks;
wfLoadExtensionMessages('ImageMap');
$lines = explode("\n", $input);
$first = true;
$lineNum = 0;
$mapHTML = '';
$links = array();
# Define canonical desc types to allow i18n of 'imagemap_desc_types'
$descTypesCanonical = 'top-right, bottom-right, bottom-left, top-left, none';
$descType = self::BOTTOM_RIGHT;
$defaultLinkAttribs = false;
$realmap = true;
foreach ($lines as $line) {
++$lineNum;
$externLink = false;
$line = trim($line);
if ($line == '' || $line[0] == '#') {
continue;
}
if ($first) {
$first = false;
# The first line should have an image specification on it
# Extract it and render the HTML
$bits = explode('|', $line, 2);
if (count($bits) == 1) {
$image = $bits[0];
$options = '';
} else {
list($image, $options) = $bits;
}
$imageTitle = Title::newFromText($image);
if (!$imageTitle || $imageTitle->getNamespace() != NS_IMAGE) {
return self::error('imagemap_no_image');
}
if (wfIsBadImage($imageTitle->getDBkey(), $parser->mTitle)) {
return self::error('imagemap_bad_image');
}
// Parse the options so we can use links and the like in the caption
$parsedOptions = $parser->recursiveTagParse($options);
$imageHTML = $parser->makeImage($imageTitle, $parsedOptions);
$parser->replaceLinkHolders($imageHTML);
$imageHTML = $parser->mStripState->unstripBoth($imageHTML);
$imageHTML = Sanitizer::normalizeCharReferences($imageHTML);
$parser->mOutput->addImage($imageTitle->getDBkey());
$domDoc = new DOMDocument();
wfSuppressWarnings();
$ok = $domDoc->loadXML($imageHTML);
wfRestoreWarnings();
if (!$ok) {
return self::error('imagemap_invalid_image');
}
$xpath = new DOMXPath($domDoc);
$imgs = $xpath->query('//img');
if (!$imgs->length) {
return self::error('imagemap_invalid_image');
}
$imageNode = $imgs->item(0);
$thumbWidth = $imageNode->getAttribute('width');
$thumbHeight = $imageNode->getAttribute('height');
if (function_exists('wfFindFile')) {
$imageObj = wfFindFile($imageTitle);
} else {
// Old MW
$imageObj = wfFindFile($imageTitle);
}
if (!$imageObj || !$imageObj->exists()) {
return self::error('imagemap_invalid_image');
}
# Add the linear dimensions to avoid inaccuracy in the scale
# factor when one is much larger than the other
# (sx+sy)/(x+y) = s
$denominator = $imageObj->getWidth() + $imageObj->getHeight();
$numerator = $thumbWidth + $thumbHeight;
if ($denominator <= 0 || $numerator <= 0) {
return self::error('imagemap_invalid_image');
}
$scale = $numerator / $denominator;
continue;
}
# Handle desc spec
$cmd = strtok($line, " \t");
if ($cmd == 'desc') {
$typesText = wfMsgForContent('imagemap_desc_types');
if ($descTypesCanonical != $typesText) {
// i18n desc types exists
$typesText = $descTypesCanonical . ', ' . $typesText;
}
$types = array_map('trim', explode(',', $typesText));
$type = trim(strtok(''));
$descType = array_search($type, $types);
if ($descType > 4) {
// A localized descType is used. Subtract 5 to reach the canonical desc type.
$descType = $descType - 5;
}
if ($descType === false || $descType < 0) {
// <0? In theory never, but paranoia...
return self::error('imagemap_invalid_desc', $typesText);
}
//.........这里部分代码省略.........
示例8: replaceInternalLinks
//.........这里部分代码省略.........
$text = $this->replaceInternalLinks($text);
$s .= "{$prefix}[[{$link}|{$text}";
# note: no $trail, because without an end, there *is* no trail
wfProfileOut("{$fname}-might_be_img");
continue;
}
} else {
#it's not an image, so output it raw
$s .= "{$prefix}[[{$link}|{$text}";
# note: no $trail, because without an end, there *is* no trail
wfProfileOut("{$fname}-might_be_img");
continue;
}
wfProfileOut("{$fname}-might_be_img");
}
$wasblank = '' == $text;
if ($wasblank) {
$text = $link;
}
# Link not escaped by : , create the various objects
if ($noforce) {
# Interwikis
wfProfileIn("{$fname}-interwiki");
if ($iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName($iw)) {
$this->mOutput->addLanguageLink($nt->getFullText());
$s = rtrim($s . $prefix);
$s .= trim($trail, "\n") == '' ? '' : $prefix . $trail;
wfProfileOut("{$fname}-interwiki");
continue;
}
wfProfileOut("{$fname}-interwiki");
if ($ns == NS_IMAGE) {
wfProfileIn("{$fname}-image");
if (!wfIsBadImage($nt->getDBkey(), $this->mTitle)) {
# recursively parse links inside the image caption
# actually, this will parse them in any other parameters, too,
# but it might be hard to fix that, and it doesn't matter ATM
$text = $this->replaceExternalLinks($text);
$text = $this->replaceInternalLinks($text);
# cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
$s .= $prefix . $this->armorLinks($this->makeImage($nt, $text)) . $trail;
$this->mOutput->addImage($nt->getDBkey());
wfProfileOut("{$fname}-image");
continue;
} else {
# We still need to record the image's presence on the page
$this->mOutput->addImage($nt->getDBkey());
}
wfProfileOut("{$fname}-image");
}
if ($ns == NS_CATEGORY) {
wfProfileIn("{$fname}-category");
$s = rtrim($s . "\n");
# bug 87
if ($wasblank) {
$sortkey = $this->getDefaultSort();
} else {
$sortkey = $text;
}
$sortkey = Sanitizer::decodeCharReferences($sortkey);
$sortkey = str_replace("\n", '', $sortkey);
$sortkey = $wgContLang->convertCategoryKey($sortkey);
$this->mOutput->addCategory($nt->getDBkey(), $sortkey);
/**
* Strip the whitespace Category links produce, see bug 87
* @todo We might want to use trim($tmp, "\n") here.
示例9: thumbToHTML
/**
*
* @param File $img
* @param Title $nt
* @param string $text
* @param string $alt
* @param type $descQuery
* @return string
*/
private function thumbToHTML($img, $nt, $text = '', $alt = '', $descQuery = '')
{
if (!$img) {
$html = '<a class="CarError" style="height: ' . $this->mThumbHeight . 'px; width: ' . $this->mThumbWidth . 'px;">' . htmlspecialchars($nt->getText()) . '</a>';
} else {
if ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
$html = '<a class="CarError" style="height: ' . $this->mThumbHeight . 'px; width: ' . $this->mThumbWidth . 'px;">' . Linker::link($nt, htmlspecialchars($nt->getText()), array(), array(), array('known', 'noclasses')) . '</a>';
} else {
if (self::imgIsVertical($img)) {
$params = array('height' => $this->mPhotoHeight, 'width' => $this->mThumbHeight);
} else {
$params = array('height' => $this->mThumbHeight, 'width' => $this->mPhotoWidth);
}
if (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$html = '<a class="CarError" style="height: ' . $this->mThumbHeight . 'px; width: ' . $this->mThumbWidth . 'px;"></a>';
} else {
$imageParameters = array('desc-link' => true, 'desc-query' => $descQuery, 'alt' => $alt);
# 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);
}
}
}
return $html;
}
示例10: renderSlideshow
//.........这里部分代码省略.........
$caption = $linkOverlay = '';
// render caption overlay
if ($text != '') {
$caption = Xml::openElement('span', array('class' => 'wikia-slideshow-image-caption')) . Xml::openElement('span', array('class' => 'wikia-slideshow-image-caption-inner')) . $text . Xml::closeElement('span') . Xml::closeElement('span');
}
// parse link
$linkAttribs = $this->parseLink($nt->getLocalUrl(), $nt->getText(), $link);
// extra link tag attributes
$linkAttribs['id'] = "{$id}-{$index}";
$linkAttribs['style'] = 'width: ' . ($params['width'] - 80) . 'px';
if ($link == '') {
// tooltip to be used for not-linked images
$linkAttribs['title'] = wfMessage('wikiaPhotoGallery-slideshow-view-popout-tooltip')->text();
$linkAttribs['class'] = 'wikia-slideshow-image';
unset($linkAttribs['href']);
} else {
// linked images
$linkAttribs['class'] .= ' wikia-slideshow-image';
// support |linktext= syntax
if ($this->mData['images'][$p]['linktext'] != '') {
$linkText = $this->mData['images'][$p]['linktext'];
} else {
$linkText = $link;
}
// add link overlay
$linkOverlay = Xml::openElement('span', array('class' => 'wikia-slideshow-link-overlay')) . wfMessage('wikiaPhotoGallery-slideshow-view-link-overlay', Sanitizer::removeHTMLtags($linkText))->text() . Xml::closeElement('span');
}
// generate HTML for a single slideshow image
$thumbHtml = null;
$liAttribs = array('title' => null);
if ($nt->getNamespace() != NS_FILE || !$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbHtml = '<a class="image broken-image new" style="line-height: ' . $this->mHeights . 'px;">' . $nt->getText() . '</a>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbHtml = '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . $sk->makeKnownLinkObj($nt, $nt->getText()) . '</div>';
} elseif (!($thumb = $img->transform($thumbParams))) {
# Error generating thumbnail.
$thumbHtml = '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$thumbAttribs = array('data-src' => $thumb->url, 'class' => 'thumbimage', 'width' => $thumb->width, 'height' => $thumb->height, 'style' => 'border: 0px;', 'data-image-name' => $img->getTitle()->getText(), 'data-image-key' => $img->getTitle()->getDBKey());
if (!empty($this->mData['images'][$p]['data-caption'])) {
$thumbAttribs['data-caption'] = $this->mData['images'][$p]['data-caption'];
}
$thumbHtml = Xml::element('img', $thumbAttribs);
}
// add CSS class so we can show first slideshow image before JS is loaded
if ($index == 0) {
$liAttribs['class'] = 'wikia-slideshow-first-image';
}
$slideshowHtml .= Xml::openElement('li', $liAttribs) . $thumbHtml . Xml::element('a', $linkAttribs, ' ') . $caption . $linkOverlay . '</li>';
$index++;
// Call parser transform hook
if ($this->mParser && is_object($img) && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
if (is_object($thumb)) {
wfDebug(__METHOD__ . ": image '" . $nt->getText() . "' {$thumb->width}x{$thumb->height}\n");
}
}
$slideshowHtml .= Xml::closeElement('ul');
$slideshowHtml .= Xml::closeElement('div');
// render prev/next buttons
global $wgBlankImgUrl;
$top = ($params['height'] >> 1) - 30 + 5;
$slideshowHtml .= Xml::openElement('div', array('class' => 'wikia-slideshow-prev-next'));
示例11: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
* @return string
*/
function toHTML()
{
if ($this->mPerRow > 0) {
$maxwidth = $this->mPerRow * ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS);
$oldStyle = isset($this->mAttribs['style']) ? $this->mAttribs['style'] : '';
# _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle;
}
$attribs = Sanitizer::mergeAttributes(array('class' => 'gallery'), $this->mAttribs);
$output = Xml::openElement('ul', $attribs);
if ($this->mCaption) {
$output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
}
$lang = $this->getLang();
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
# Output each image...
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# "text" means "caption" here
$alt = $pair[2];
$link = $pair[3];
$descQuery = false;
if ($nt->getNamespace() == NS_FILE) {
# Get the file...
if ($this->mParser instanceof Parser) {
# Give extensions a chance to select the file revision for us
$options = array();
wfRunHooks('BeforeParserFetchFileAndTitle', array($this->mParser, $nt, &$options, &$descQuery));
# Fetch and register the file (file title may be different via hooks)
list($img, $nt) = $this->mParser->fetchFileAndTitle($nt, $options);
} else {
$img = wfFindFile($nt);
}
} else {
$img = false;
}
if (!$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . Linker::link($nt, htmlspecialchars($nt->getText()), array(), array(), array('known', 'noclasses')) . '</div>';
} elseif (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$vpad = (self::THUMB_PADDING + $this->mHeights - $thumb->height) / 2;
$imageParameters = array('desc-link' => true, 'desc-query' => $descQuery, 'alt' => $alt, 'custom-url-link' => $link);
# In the absence of both alt text and caption, fall back on providing screen readers with the filename as alt text
if ($alt == '' && $text == '') {
$imageParameters['alt'] = $nt->getText();
}
# Set both fixed width and min-height.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="width: ' . ($this->mWidths + self::THUMB_PADDING) . 'px;">' . '<div style="margin:' . $vpad . 'px auto;">' . $thumb->toHtml($imageParameters) . '</div></div>';
// Call parser transform hook
if ($this->mParser && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
}
//TODO
// $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
// $ul = Linker::link( $linkTarget, $ut );
if ($this->mShowBytes) {
if ($img) {
$fileSize = htmlspecialchars($lang->formatSize($img->getSize()));
} else {
$fileSize = wfMessage('filemissing')->escaped();
}
$fileSize = "{$fileSize}<br />\n";
} else {
$fileSize = '';
}
$textlink = $this->mShowFilename ? Linker::link($nt, htmlspecialchars($lang->truncate($nt->getText(), $this->mCaptionLength)), array(), array(), array('known', 'noclasses')) . "<br />\n" : '';
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
# Weird double wrapping (the extra div inside the li) needed due to FF2 bug
# Can be safely removed if FF2 falls completely out of existence
$output .= "\n\t\t" . '<li class="gallerybox" style="width: ' . ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING) . 'px">' . '<div style="width: ' . ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING) . 'px">' . $thumbhtml . "\n\t\t\t" . '<div class="gallerytext">' . "\n" . $textlink . $text . $fileSize . "\n\t\t\t</div>" . "\n\t\t</div></li>";
}
$output .= "\n</ul>";
return $output;
}
示例12: testWfIsBadImage
/**
* @dataProvider provideWfIsBadImageList
* @covers ::wfIsBadImage
*/
public function testWfIsBadImage($name, $title, $blacklist, $expected, $desc)
{
$this->assertEquals($expected, wfIsBadImage($name, $title, $blacklist), $desc);
}
示例13: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
* @return string
*/
function toHTML() {
if ( $this->mPerRow > 0 ) {
$maxwidth = $this->mPerRow * ( $this->mWidths + $this->getAllPadding() );
$oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : '';
# _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle;
}
$attribs = Sanitizer::mergeAttributes(
array( 'class' => 'gallery mw-gallery-' . $this->mMode ), $this->mAttribs );
$modules = $this->getModules();
if ( $this->mParser ) {
$this->mParser->getOutput()->addModules( $modules );
} else {
$this->getOutput()->addModules( $modules );
}
$output = Xml::openElement( 'ul', $attribs );
if ( $this->mCaption ) {
$output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
}
$lang = $this->getRenderLang();
# Output each image...
foreach ( $this->mImages as $pair ) {
$nt = $pair[0];
$text = $pair[1]; # "text" means "caption" here
$alt = $pair[2];
$link = $pair[3];
$descQuery = false;
if ( $nt->getNamespace() === NS_FILE ) {
# Get the file...
if ( $this->mParser instanceof Parser ) {
# Give extensions a chance to select the file revision for us
$options = array();
wfRunHooks( 'BeforeParserFetchFileAndTitle',
array( $this->mParser, $nt, &$options, &$descQuery ) );
# Fetch and register the file (file title may be different via hooks)
list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $options );
} else {
$img = wfFindFile( $nt );
}
} else {
$img = false;
}
$params = $this->getThumbParams( $img );
// $pair[4] is per image handler options
$transformOptions = $params + $pair[4];
$thumb = false;
if ( !$img ) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ( $this->getThumbPadding() + $this->mHeights ) . 'px;">'
. htmlspecialchars( $nt->getText() ) . '</div>';
if ( $this->mParser instanceof Parser ) {
$this->mParser->addTrackingCategory( 'broken-file-category' );
}
} elseif ( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ( $this->getThumbPadding() + $this->mHeights ) . 'px;">' .
Linker::link(
$nt,
htmlspecialchars( $nt->getText() ),
array(),
array(),
array( 'known', 'noclasses' )
) .
'</div>';
} elseif ( !( $thumb = $img->transform( $transformOptions ) ) ) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ( $this->getThumbPadding() + $this->mHeights ) . 'px;">'
. htmlspecialchars( $img->getLastError() ) . '</div>';
} else {
$vpad = $this->getVPad( $this->mHeights, $thumb->getHeight() );
$imageParameters = array(
'desc-link' => true,
'desc-query' => $descQuery,
'alt' => $alt,
'custom-url-link' => $link
);
# In the absence of both alt text and caption, fall back on providing screen readers with the filename as alt text
if ( $alt == '' && $text == '' ) {
$imageParameters['alt'] = $nt->getText();
//.........这里部分代码省略.........
示例14: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
*/
function toHTML()
{
global $wgLang;
$sk = $this->getSkin();
if ($this->mPerRow > 0) {
$maxwidth = $this->mPerRow * ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS);
$oldStyle = isset($this->mAttribs['style']) ? $this->mAttribs['style'] : "";
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle;
}
$attribs = Sanitizer::mergeAttributes(array('class' => 'gallery'), $this->mAttribs);
$s = Xml::openElement('ul', $attribs);
if ($this->mCaption) {
$s .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
}
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
$i = 0;
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# "text" means "caption" here
# Give extensions a chance to select the file revision for us
$time = $descQuery = false;
wfRunHooks('BeforeGalleryFindFile', array(&$this, &$nt, &$time, &$descQuery));
if ($nt->getNamespace() == NS_FILE) {
$img = wfFindFile($nt, array('time' => $time));
} else {
$img = false;
}
if (!$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . $sk->link($nt, htmlspecialchars($nt->getText()), array(), array(), array('known', 'noclasses')) . '</div>';
} elseif (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
//We get layout problems with the margin, if the image is smaller
//than the line-height, so we less margin in these cases.
$minThumbHeight = $thumb->height > 17 ? $thumb->height : 17;
$vpad = floor((self::THUMB_PADDING + $this->mHeights - $minThumbHeight) / 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();
}
# Set both fixed width and min-height.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="width: ' . ($this->mWidths + self::THUMB_PADDING) . 'px;">' . '<div style="margin:' . $vpad . 'px auto;">' . $thumb->toHtml($imageParameters) . '</div></div>';
// Call parser transform hook
if ($this->mParser && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
}
//TODO
// $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
// $ul = $sk->link( $linkTarget, $ut );
if ($this->mShowBytes) {
if ($img) {
$nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($img->getSize()));
} else {
$nb = wfMsgHtml('filemissing');
}
$nb = "{$nb}<br />\n";
} else {
$nb = '';
}
$textlink = $this->mShowFilename ? $sk->link($nt, htmlspecialchars($wgLang->truncate($nt->getText(), $this->mCaptionLength)), array(), array(), array('known', 'noclasses')) . "<br />\n" : '';
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
# Weird double wrapping in div needed due to FF2 bug
# Can be safely removed if FF2 falls completely out of existance
$s .= "\n\t\t" . '<li class="gallerybox" style="width: ' . ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING) . 'px">' . '<div style="width: ' . ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING) . 'px">' . $thumbhtml . "\n\t\t\t" . '<div class="gallerytext">' . "\n" . $textlink . $text . $nb . "\n\t\t\t</div>" . "\n\t\t</div></li>";
++$i;
}
$s .= "\n</ul>";
return $s;
}
示例15: photoToHTML
private function photoToHTML($img, $nt, $text = '', $alt = '', $titleLink = null, $descQuery = '')
{
//Some ugly alignment logic used later
$verticalPadding = 0;
$horizontalPadding = 0;
$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 == '') {
if ($text == '') {
$imageParameters['alt'] = $nt->getText();
} else {
$imageParameters['alt'] = htmlspecialchars($text);
}
}
$html = $thumb->toHtml($imageParameters);
//Some ugly alignment logic
$thumbHeight = $thumb->getHeight();
$thumbWidth = $thumb->getWidth();
if ($this->mPhotoHeight > $thumbHeight) {
$verticalPadding = floor(($this->mPhotoHeight - $thumbHeight) / 2);
}
if ($this->mPhotoWidth > $thumbWidth) {
$horizontalPadding = floor(($this->mPhotoWidth - $thumbWidth) / 2);
}
// Call parser transform hook
if ($this->mParser && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
}
}
}
$wrapperHeight = $this->mPhotoHeight - 2 * $verticalPadding + 2;
$wrapperWidth = $this->mPhotoWidth - 2 * $horizontalPadding + 2;
$html = Html::rawElement('div', array('class' => 'wrapper', 'style' => 'height:' . $wrapperHeight . 'px; width:' . $wrapperWidth . 'px; padding:' . $verticalPadding . 'px ' . $horizontalPadding . 'px;'), $html);
$html .= Html::rawElement('div', array('class' => 'caption'), $text);
return $html;
}