From 7f61f319ff69cae39b10aa17d38862f3bb504a6c Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Sat, 15 Oct 2011 20:30:37 +0000 Subject: [PATCH] Per r97671, add $wgEnableAutoRotation setting that can be used to explicitly disable auto-rotation. --- RELEASE-NOTES-1.18 | 2 ++ includes/DefaultSettings.php | 6 ++++++ includes/Setup.php | 5 +++++ includes/media/ExifBitmap.php | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/RELEASE-NOTES-1.18 b/RELEASE-NOTES-1.18 index 1885494b91..074ff90d0a 100644 --- a/RELEASE-NOTES-1.18 +++ b/RELEASE-NOTES-1.18 @@ -85,6 +85,8 @@ production. * New hook "Collation::factory" to allow extensions to create custom category collations. * $wgGroupPermissions now supports per namespace permissions. +* $wgEnableAutoRotation enables or disables auto-rotation. Leaving it set to + null will cause MediaWiki to determine if auto-rotation is available. === New features in 1.18 === * BREAKING CHANGE: action=watch / action=unwatch now requires a token. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 331742822c..a888c3adbc 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -744,6 +744,12 @@ $wgShowArchiveThumbnails = true; /** Obsolete, always true, kept for compatibility with extensions */ $wgUseImageResize = true; +/** + * If set to true, images that contain certain the exif orientation tag will + * be rotated accordingly. If set to null, try to auto-detect whether a scaler + * is available that can rotate. + */ +$wgEnableAutoRotation = null; /** * Internal name of virus scanner. This servers as a key to the diff --git a/includes/Setup.php b/includes/Setup.php index 46829941fa..afde02fa80 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -187,6 +187,11 @@ if ( $wgUseInstantCommons ) { ); } +if ( is_null( $wgEnableAutoRotation ) ) { + // Only enable auto-rotation when the bitmap handler can rotate + $wgEnableAutoRotation = BitmapHandler::canRotate(); +} + if ( $wgRCFilterByAge ) { # # Trim down $wgRCLinkDays so that it only lists links which are valid # # as determined by $wgRCMaxAge. diff --git a/includes/media/ExifBitmap.php b/includes/media/ExifBitmap.php index 6b4bf7a0de..96f5d21d96 100644 --- a/includes/media/ExifBitmap.php +++ b/includes/media/ExifBitmap.php @@ -162,6 +162,11 @@ class ExifBitmapHandler extends BitmapHandler { * @return int 0, 90, 180 or 270 */ public function getRotation( $file ) { + global $wgEnableAutoRotation; + if ( !$wgEnableAutoRotation ) { + return 0; + } + $data = $file->getMetadata(); return $this->getRotationForExif( $data ); } -- 2.20.1