Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / media / Tiff.php
index 6964170..2e73249 100644 (file)
@@ -27,6 +27,8 @@
  * @ingroup Media
  */
 class TiffHandler extends ExifBitmapHandler {
+       const EXPENSIVE_SIZE_LIMIT = 10485760; // TIFF files over 10M are considered expensive to thumbnail
+
        /**
         * Conversion to PNG for inline display can be disabled here...
         * Note scaling should work with ImageMagick, but may not with GD scaling.
@@ -38,7 +40,7 @@ class TiffHandler extends ExifBitmapHandler {
         * @param File $file
         * @return bool
         */
-       function canRender( $file ) {
+       public function canRender( $file ) {
                global $wgTiffThumbnailType;
 
                return (bool)$wgTiffThumbnailType
@@ -52,7 +54,7 @@ class TiffHandler extends ExifBitmapHandler {
         * @param File $file
         * @return bool
         */
-       function mustRender( $file ) {
+       public function mustRender( $file ) {
                return true;
        }
 
@@ -86,7 +88,7 @@ class TiffHandler extends ExifBitmapHandler {
                                $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
 
                                return serialize( $meta );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // BitmapMetadataHandler throws an exception in certain exceptional
                                // cases like if file does not exist.
                                wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
@@ -97,4 +99,8 @@ class TiffHandler extends ExifBitmapHandler {
                        return '';
                }
        }
+
+       public function isExpensiveToThumbnail( $file ) {
+               return $file->getSize() > static::EXPENSIVE_SIZE_LIMIT;
+       }
 }