/** * Make an image link * @param Title $title Title object * @param File $file File object, or false if it doesn't exist * * @param array $frameParams Associative array of parameters external to the media handler. * Boolean parameters are indicated by presence or absence, the value is arbitrary and * will often be false. * thumbnail If present, downscale and frame * manualthumb Image name to use as a thumbnail, instead of automatic scaling * framed Shows image in original size in a frame * frameless Downscale but don't frame * upright If present, tweak default sizes for portrait orientation * upright_factor Fudge factor for "upright" tweak (default 0.75) * border If present, show a border around the image * align Horizontal alignment (left, right, center, none) * valign Vertical alignment (baseline, sub, super, top, text-top, middle, * bottom, text-bottom) * alt Alternate text for image (i.e. alt attribute). Plain text. * caption HTML for image caption. * * @param array $handlerParams Associative array of media handler parameters, to be passed * to transform(). Typical keys are "width" and "page". * @param string $time, timestamp of the file, set as false for current */ function makeImageLink2(Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false) { global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright; if ($file && !$file->allowInlineDisplay()) { wfDebug(__METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n"); return $this->makeKnownLinkObj($title); } if (!$file) { return; } // Shortcuts $fp =& $frameParams; $hp =& $handlerParams; $section = WikihowArticleEditor::getImageSection($file->getName()); // Clean up parameters $page = isset($hp['page']) ? $hp['page'] : false; if (!isset($fp['align'])) { $fp['align'] = ''; } if (!isset($fp['alt'])) { $fp['alt'] = ''; } $imageClass = ""; $prefix = $postfix = ''; $isPortrait = false; $isLarge = false; $sourceWidth = $file->getWidth(); $sourceHeight = $file->getHeight(); if ($sourceHeight > $sourceWidth) { if ($sourceWidth > 200) { $isPortrait = true; $isLarge = true; } } else { //landscape if ($sourceWidth > 400) { $isLarge = true; } } if ($section != "summary" && $section != "steps") { $isLarge = false; } if ($section == "summary") { //for intro they must specify 625 and center to have it shown if ($hp['width'] >= 625) { $imageClass .= " introimage "; } } if ($file && !isset($hp['width'])) { $hp['width'] = $file->getWidth($page); if (isset($fp['thumbnail']) || isset($fp['framed']) || isset($fp['frameless']) || !$hp['width']) { $wopt = $wgUser->getOption('thumbsize'); if (!isset($wgThumbLimits[$wopt])) { $wopt = User::getDefaultOption('thumbsize'); } // Reduce width for upright images when parameter 'upright' is used if (isset($fp['upright']) && $fp['upright'] == 0) { $fp['upright'] = $wgThumbUpright; } // Use width which is smaller: real image width or user preference width // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs $prefWidth = isset($fp['upright']) ? round($wgThumbLimits[$wopt] * $fp['upright'], -1) : $wgThumbLimits[$wopt]; if ($hp['width'] <= 0 || $prefWidth < $hp['width']) { $hp['width'] = $prefWidth; } } } //not using thumbs on large images anymore if (!$isLarge && isset($fp['thumbnail']) || isset($fp['manualthumb']) || isset($fp['framed'])) { # Create a thumbnail. Alignment depends on language # writing direction, # right aligned for left-to-right- # languages ("Western languages"), left-aligned # for right-to-left-languages ("Semitic languages") # # If thumbnail width has not been provided, it is set # to the default user option as specified in Language*.php if ($fp['align'] == '') { $fp['align'] = $wgContLang->isRTL() ? 'left' : 'right'; } return $prefix . $this->makeThumbLink2($title, $file, $fp, $hp, $time) . $postfix; } if ($file && isset($fp['frameless'])) { # For "frameless" option: do not present an image bigger than the source (for bitmap-style images) # This is the same behaviour as the "thumb" option does it already. if ($sourceWidth && !$file->mustRender() && $hp['width'] > $sourceWidth) { $hp['width'] = $sourceWidth; } } if ($file && $hp['width']) { # Create a resized image, without the additional thumbnail features if ($isLarge) { if ($isPortrait) { //it's a portrait image $height = min(550, $sourceHeight); $hp['width'] = $sourceWidth * $height / $sourceHeight; $imageClass .= " largeimage portrait"; } else { if ($isLarge) { //this is our low threshold, so show it as big as possible $hp['width'] = min(670, $sourceWidth); //now make sure it's not too tall. $newHeight = $sourceHeight * $hp['width'] / $sourceWidth; if ($newHeight > 550) { //limit all images to 550 $hp['width'] = $sourceWidth * 525 / $sourceHeight; } $imageClass .= " largeimage "; } } if ($hp['width'] < 670) { $imageClass .= " underwidth "; } } $thumb = $file->transform($hp); } else { $thumb = false; } if (!$isLarge) { $imageClass .= " t{$fp['align']}"; } if (!$thumb) { $s = $this->makeBrokenImageLinkObj($title, '', '', '', '', $time == true); } else { $s = $thumb->toHtml(array('desc-link' => true, 'href' => '', 'onclick' => 'return loadimg("' . $thumb->path . '", "' . $thumb->url . '" );', 'alt' => $fp['alt'], 'valign' => isset($fp['valign']) ? $fp['valign'] : false, 'img-class' => isset($fp['border']) ? 'thumbborder' : false)); $h = $thumb->getHeight(); $w = $thumb->getWidth(); /*$s = "<div class='rounders' style='width:{$w}px;height:{$h}px;'>$s <div class='corner top_left'></div><div class='corner top_right'></div><div class='corner bottom_left'></div><div class='corner bottom_right'></div> </div>";*/ } if ('' == $fp['align']) { $fp['align'] = 'right'; } $imageClass .= " float{$fp['align']} "; if (isset($fp['thumbnail'])) { $imageClass .= " mthumb "; } //for mobile thumb $rptLink = class_exists('InaccurateImages') ? InaccurateImages::getReportImageLink() : ""; $s = "<div class='mwimg {$imageClass}' style='max-width:{$hp['width']}px'>{$rptLink}{$s}</div>"; return str_replace("\n", ' ', $prefix . $s . $postfix); }