global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
$wgUseImageResize, $wgRepositoryBaseUrl;
$this->img = Image::newFromTitle( $this->mTitle );
- $url = $this->img->getViewURL();
+ $full_url = $this->img->getViewURL();
$anchoropen = '';
$anchorclose = '';
- if ( $wgUseImageResize ) {
- if( $wgUser->getOption( 'imagesize' ) == '' ) {
- $sizeSel = User::getDefaultOption( 'imagesize' );
- } else {
- $sizeSel = IntVal( $wgUser->getOption( 'imagesize' ) );
- }
- if( !isset( $wgImageLimits[$sizeSel] ) ) {
- $sizeSel = User::getDefaultOption( 'imagesize' );
- }
- $max = $wgImageLimits[$sizeSel];
- $maxWidth = $max[0];
- $maxHeight = $max[1];
+
+ if( $wgUser->getOption( 'imagesize' ) == '' ) {
+ $sizeSel = User::getDefaultOption( 'imagesize' );
+ } else {
+ $sizeSel = IntVal( $wgUser->getOption( 'imagesize' ) );
+ }
+ if( !isset( $wgImageLimits[$sizeSel] ) ) {
+ $sizeSel = User::getDefaultOption( 'imagesize' );
}
+ $max = $wgImageLimits[$sizeSel];
+ $maxWidth = $max[0];
+ $maxHeight = $max[1];
if ( $this->img->exists() ) {
$width = $this->img->getWidth();
$height = $this->img->getHeight();
$msg = wfMsg('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) );
- if ( $width > $maxWidth && $wgUseImageResize ) {
- $anchoropen = "<a href=\"{$url}\">";
- $anchorclose = "<br>{$msg}</a>";
-
- $url = $this->img->createThumb( $maxWidth );
+ if ( $width > $maxWidth ) {
$height = floor( $height * $maxWidth / $width );
$width = $maxWidth;
}
- if ( $height > $maxHeight && $wgUseImageResize ) {
- $anchoropen = "<a href=\"{$url}\">";
- $anchorclose = "<br>{$msg}</a>";
-
+ if ( $height > $maxHeight ) {
$width = floor( $width * $maxHeight / $height );
$height = $maxHeight;
- $url = $this->img->createThumb( $width );
}
- $s = "<div class=\"fullImageLink\">" . $anchoropen .
+ if ( $width != $this->img->getWidth() || $height != $this->img->getHeight() ) {
+ if( $wgUseImageResize ) {
+ $thumbnail = $this->img->getThumbnail( $width );
+
+ if ( ( ! $this->img->mustRender() )
+ && ( $thumbnail->getSize() > $this->img->getSize() ) ) {
+ # the thumbnail is bigger thatn the original image.
+ # show the original image instead of the thumb.
+ $url = $full_url;
+ $width = $this->img->getWidth();
+ $height = $this->img->getHeight();
+ } else {
+ $url = $thumbnail->getUrl();
+ }
+ } else {
+ # No resize ability? Show the full image, but scale
+ # it down in the browser so it fits on the page.
+ $url = $full_url;
+ }
+ $anchoropen = "<a href=\"{$full_url}\">";
+ $anchorclose = "<br />{$msg}</a>";
+ } else {
+ $url = $full_url;
+ }
+ $s = '<div class="fullImageLink">' . $anchoropen .
"<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" alt=\"" .
- htmlspecialchars( $wgRequest->getVal( 'image' ) )."\" />" . $anchorclose . "</div>";
+ htmlspecialchars( $wgRequest->getVal( 'image' ) ).'" />' . $anchorclose . '</div>';
} else {
- $s = "<div class=\"fullMedia\">".$sk->makeMediaLink($this->img->getName(),"")."</div>";
+ $s = "<div class=\"fullMedia\">" . $sk->makeMediaLink( $this->img->getName(),'' ) . '</div>';
}
$wgOut->addHTML( $s );
if($this->img->fromSharedDirectory) {
$wgOut->addHTML( '<h2>' . wfMsg( 'imagelinks' ) . "</h2>\n" );
$dbr =& wfGetDB( DB_SLAVE );
- $cur = $dbr->tableName( 'cur' );
+ $page = $dbr->tableName( 'page' );
$imagelinks = $dbr->tableName( 'imagelinks' );
- $sql = "SELECT cur_namespace,cur_title FROM $imagelinks,$cur WHERE il_to=" .
- $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=cur_id"
+ $sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" .
+ $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=page_id"
. " LIMIT 500"; # quickie emergency brake
$res = $dbr->query( $sql, DB_SLAVE, "Article::imageLinks" );
$sk = $wgUser->getSkin();
while ( $s = $dbr->fetchObject( $res ) ) {
- $name = Title::MakeTitle( $s->cur_namespace, $s->cur_title );
+ $name = Title::MakeTitle( $s->page_namespace, $s->page_title );
$link = $sk->makeKnownLinkObj( $name, "" );
$wgOut->addHTML( "<li>{$link}</li>\n" );
}
# Better double-check that it hasn't been deleted yet!
$wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
- if ( !is_null( $image ) ) {
- if ( '' == trim( $image ) ) {
- $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
- return;
- }
+ if ( ( !is_null( $image ) )
+ && ( '' == trim( $image ) ) ) {
+ $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
+ return;
}
# Deleting old images doesn't require confirmation