}
}
- # Check if the file is smaller than the maximum image area for thumbnailing
- # For historical reasons, hook starts with BitmapHandler
- $checkImageAreaHookResult = null;
- Hooks::run(
- 'BitmapHandlerCheckImageArea',
- array( $image, &$params, &$checkImageAreaHookResult )
- );
-
- if ( is_null( $checkImageAreaHookResult ) ) {
- global $wgMaxImageArea;
-
- if ( $srcWidth * $srcHeight > $wgMaxImageArea
- && !( $image->getMimeType() == 'image/jpeg'
- && $this->getScalerType( false, false ) == 'im' )
- ) {
- # Only ImageMagick can efficiently downsize jpg images without loading
- # the entire file in memory
- return false;
- }
- } else {
- return $checkImageAreaHookResult;
- }
-
return true;
}
return $this->getClientScalingThumbnailImage( $image, $scalerParams );
}
+ if ( $image->isTransformedLocally() && !$this->isImageAreaOkForThumbnaling( $image, $params ) ) {
+ global $wgMaxImageArea;
+ return new TransformTooBigImageAreaError( $params, $wgMaxImageArea );
+ }
+
if ( $flags & self::TRANSFORM_LATER ) {
wfDebug( __METHOD__ . ": Transforming later per flags.\n" );
$newParams = array(
public function mustRender( $file ) {
return $this->canRotate() && $this->getRotation( $file ) != 0;
}
+
+ /**
+ * Check if the file is smaller than the maximum image area for thumbnailing.
+ *
+ * Runs the 'BitmapHandlerCheckImageArea' hook.
+ *
+ * @param File $file
+ * @param array $params
+ * @return bool
+ * @since 1.25
+ */
+ public function isImageAreaOkForThumbnaling( $file, &$params ) {
+ global $wgMaxImageArea;
+
+ # For historical reasons, hook starts with BitmapHandler
+ $checkImageAreaHookResult = null;
+ Hooks::run(
+ 'BitmapHandlerCheckImageArea',
+ array( $file, &$params, &$checkImageAreaHookResult )
+ );
+
+ if ( !is_null( $checkImageAreaHookResult ) ) {
+ // was set by hook, so return that value
+ return (bool)$checkImageAreaHookResult;
+ }
+
+ $srcWidth = $file->getWidth( $params['page'] );
+ $srcHeight = $file->getHeight( $params['page'] );
+
+ if ( $srcWidth * $srcHeight > $wgMaxImageArea
+ && !( $file->getMimeType() == 'image/jpeg'
+ && $this->getScalerType( false, false ) == 'im' )
+ ) {
+ # Only ImageMagick can efficiently downsize jpg images without loading
+ # the entire file in memory
+ return false;
+ }
+ return true;
+ }
}