-
- return true;
- }
-
- /**
- * Check if the file is smaller than the maximum image area for
- * thumbnailing. Check will always pass if the scaler is 'hookaborted' or
- * if the scaler is 'im' and the mime type is 'image/jpeg'
- *
- * @param File $image
- * @param string $scaler
- */
- function checkImageArea( $image, $scaler ) {
- global $wgMaxImageArea;
- # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
- # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
- # an exception for it.
-
-
- if ( $image->getMimeType() == 'image/jpeg' && $scaler == 'im' )
- {
- # ImageMagick can efficiently downsize jpg images without loading
- # the entire file in memory
- return true;
- }
-
- if ( $scaler == 'hookaborted' )
- {
- # If a hook wants to transform the image, it is responsible for
- # checking the image size, so abort here
- return true;
+
+ # Check if the file is smaller than the maximum image area for thumbnailing
+ $checkImageAreaHookResult = null;
+ wfRunHooks( 'BitmapHandlerCheckImageArea', array( $image, &$params, &$checkImageAreaHookResult ) );
+ if ( is_null( $checkImageAreaHookResult ) ) {
+ global $wgMaxImageArea;
+
+ if ( $srcWidth * $srcHeight > $wgMaxImageArea &&
+ !( $image->getMimeType() == 'image/jpeg' &&
+ self::getScalerType( false, false ) == 'im' ) ) {
+ # Only ImageMagick can efficiently downsize jpg images without loading
+ # the entire file in memory
+ return false;
+ }
+ } else {
+ return $checkImageAreaHookResult;