X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/mediawiki.git/blobdiff_plain/87219ebd28426c6d21cb545233ee52f5f7af7dfd..refs/tags/mediawiki-1.17.0:/includes/media/GIF.php diff --git a/includes/media/GIF.php b/includes/media/GIF.php index dbe5f813..c4ede331 100644 --- a/includes/media/GIF.php +++ b/includes/media/GIF.php @@ -1,5 +1,7 @@ parsedGIFMetadata) ) { + if ( !isset( $image->parsedGIFMetadata ) ) { try { $image->parsedGIFMetadata = GIFMetadataExtractor::getMetadata( $filename ); } catch( Exception $e ) { @@ -22,7 +24,7 @@ class GIFHandler extends BitmapHandler { } } - return serialize($image->parsedGIFMetadata); + return serialize( $image->parsedGIFMetadata ); } @@ -39,22 +41,41 @@ class GIFHandler extends BitmapHandler { return $width * $height; } } + + function isAnimatedImage( $image ) { + $ser = $image->getMetadata(); + if ($ser) { + $metadata = unserialize($ser); + if( $metadata['frameCount'] > 1 ) return true; + } + return false; + } function getMetadataType( $image ) { return 'parsed-gif'; } + function isMetadataValid( $image, $metadata ) { + wfSuppressWarnings(); + $data = unserialize( $metadata ); + wfRestoreWarnings(); + return (boolean) $data; + } + function getLongDesc( $image ) { - global $wgUser, $wgLang; - $sk = $wgUser->getSkin(); - - $metadata = @unserialize($image->getMetadata()); + global $wgLang; + + $original = parent::getLongDesc( $image ); + + wfSuppressWarnings(); + $metadata = unserialize($image->getMetadata()); + wfRestoreWarnings(); - if (!$metadata) return parent::getLongDesc( $image ); + if (!$metadata || $metadata['frameCount'] <= 1) + return $original; $info = array(); - $info[] = $image->getMimeType(); - $info[] = $sk->formatSize( $image->getSize() ); + $info[] = $original; if ($metadata['looped']) $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' ); @@ -65,8 +86,6 @@ class GIFHandler extends BitmapHandler { if ($metadata['duration']) $info[] = $wgLang->formatTimePeriod( $metadata['duration'] ); - $infoString = $wgLang->commaList( $info ); - - return "($infoString)"; + return $wgLang->commaList( $info ); } }