function normaliseParams($image, &$params) { global $wgSVGMaxSize; if (!parent::normaliseParams($image, $params)) { return false; } # Don't make an image bigger than wgMaxSVGSize $params['physicalWidth'] = $params['width']; $params['physicalHeight'] = $params['height']; if ($params['physicalWidth'] > $wgSVGMaxSize) { $srcWidth = $image->getWidth($params['page']); $srcHeight = $image->getHeight($params['page']); $params['physicalWidth'] = $wgSVGMaxSize; $params['physicalHeight'] = File::scaleHeight($srcWidth, $srcHeight, $wgSVGMaxSize); } return true; }
/** * Validate thumbnail parameters and fill in the correct height * * @param $width Integer: specified width (input/output) * @param $height Integer: height (output only) * @param $srcWidth Integer: width of the source image * @param $srcHeight Integer: height of the source image * @param $mimeType Unused * @return false to indicate that an error should be returned to the user. */ function validateThumbParams(&$width, &$height, $srcWidth, $srcHeight, $mimeType) { $width = intval($width); # Sanity check $width if ($width <= 0) { wfDebug(__METHOD__ . ": Invalid destination width: {$width}\n"); return false; } if ($srcWidth <= 0) { wfDebug(__METHOD__ . ": Invalid source width: {$srcWidth}\n"); return false; } $height = File::scaleHeight($srcWidth, $srcHeight, $width); if ($height == 0) { # Force height to be at least 1 pixel $height = 1; } return true; }
function normaliseParams($image, &$params) { $srcWidth = $image->getWidth(); $srcHeight = $image->getHeight(); $params['playertype'] = "video"; if ($srcWidth == 0 || $srcHeight == 0) { // We presume this is an audio clip $params['playertype'] = "audio"; $params['height'] = empty($params['height']) ? 20 : $params['height']; $params['width'] = empty($params['width']) ? 200 : $params['width']; } else { // Check for height param and adjust width accordingly if (isset($params['height']) && $params['height'] != -1) { if ($params['width'] * $srcHeight > $params['height'] * $srcWidth) { $params['width'] = self::fitBoxWidth($srcWidth, $srcHeight, $params['height']); } } // Make it no wider than the original //if( $params['width'] > $srcWidth ) { // $params['width'] = $srcWidth; //} // Calculate the corresponding height based on the adjusted width $params['height'] = File::scaleHeight($srcWidth, $srcHeight, $params['width']); } if (isset($params['thumbtime'])) { $length = $this->getLength($image); $time = $this->parseTimeString($params['thumbtime']); if ($time === false) { return false; } elseif ($time > $length - 1) { $params['thumbtime'] = $length - 1; } elseif ($time <= 0) { $params['thumbtime'] = 0; } } return true; }