Index: includes/Linker.php
===================================================================
--- includes/Linker.php (revision 16089)
+++ includes/Linker.php (working copy)
@@ -455,7 +455,7 @@
}
/** @todo document */
- function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false,
+ function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $unit="px", $framed = false,
$thumb = false, $manual_thumb = '', $page = null )
{
global $wgContLang, $wgUser, $wgThumbLimits, $wgGenerateThumbnailOnParse;
@@ -473,7 +473,7 @@
$url = $img->getViewURL();
$error = $prefix = $postfix = '';
- wfDebug( "makeImageLinkObj: '$width'x'$height', \"$label\"\n" );
+ wfDebug( "makeImageLinkObj: '$width'x'$height$unit', \"$label\"\n" );
if ( 'center' == $align )
{
@@ -517,24 +517,38 @@
if ( $height == false )
$height = -1;
if ( $manual_thumb == '') {
- $thumb = $img->getThumbnail( $width, $height, $wgGenerateThumbnailOnParse );
- if ( $thumb ) {
- // In most cases, $width = $thumb->width or $height = $thumb->height.
- // If not, we're scaling the image larger than it can be scaled,
- // so we send to the browser a smaller thumbnail, and let the client do the scaling.
+ if( $unit == "px" ) {
+ $thumb = $img->getThumbnail( $width, $height, $wgGenerateThumbnailOnParse );
+ if ( $thumb ) {
+ // In most cases, $width = $thumb->width or $height = $thumb->height.
+ // If not, we're scaling the image larger than it can be scaled,
+ // so we send to the browser a smaller thumbnail, and let the client do the scaling.
- if ($height != -1 && $width > $thumb->width * $height / $thumb->height) {
- // $height is the limiting factor, not $width
- // set $width to the largest it can be, such that the resulting
- // scaled height is at most $height
- $width = floor($thumb->width * $height / $thumb->height);
+ if ($height != -1 && $width > $thumb->width * $height / $thumb->height) {
+ // $height is the limiting factor, not $width
+ // set $width to the largest it can be, such that the resulting
+ // scaled height is at most $height
+ $width = floor($thumb->width * $height / $thumb->height);
+ }
+ $height = round($thumb->height * $width / $thumb->width);
+
+ wfDebug( "makeImageLinkObj: client-size set to '$width x $height'\n" );
+ $url = $thumb->getUrl();
+ } else {
+ $error = htmlspecialchars( $img->getLastError() );
}
- $height = round($thumb->height * $width / $thumb->width);
-
- wfDebug( "makeImageLinkObj: client-size set to '$width x $height'\n" );
- $url = $thumb->getUrl();
- } else {
- $error = htmlspecialchars( $img->getLastError() );
+ } elseif( $unit == "ex" || $unit == "em" ) {
+ if( $height == -1 ) {
+ $height = ($img->height/$img->width)*$width;
+ } else {
+ if( ($width/$img->width) < ($height/$img->height) ) {
+ $height = ($img->height/$img->width)*$width;
+ } else {
+ $width = ($img->width/$img->height)*$height;
+ }
+ }
+ $width = round($width,3);
+ $height = round($height,3);
}
}
} else {
@@ -542,6 +556,7 @@
$height = $img->height;
}
+
wfDebug( "makeImageLinkObj2: '$width'x'$height'\n" );
$u = $nt->escapeLocalURL();
if ( $error ) {
@@ -551,11 +566,11 @@
//$s .= "
{$alt}
{$url}
\n";
} else {
$s = '' .
- '';
+ '" longdesc="'.$u.'" />';
}
if ( '' != $align ) {
$s = "