summaryrefslogtreecommitdiff
path: root/includes/media/GIF.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
commit222b01f5169f1c7e69762e0e8904c24f78f71882 (patch)
tree8e932e12546bb991357ec48eb1638d1770be7a35 /includes/media/GIF.php
parent00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff)
update to MediaWiki 1.16.0
Diffstat (limited to 'includes/media/GIF.php')
-rw-r--r--includes/media/GIF.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/includes/media/GIF.php b/includes/media/GIF.php
new file mode 100644
index 00000000..dbe5f813
--- /dev/null
+++ b/includes/media/GIF.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * @file
+ * @ingroup Media
+ */
+
+/**
+ * Handler for GIF images.
+ *
+ * @ingroup Media
+ */
+class GIFHandler extends BitmapHandler {
+
+ function getMetadata( $image, $filename ) {
+ if ( !isset($image->parsedGIFMetadata) ) {
+ try {
+ $image->parsedGIFMetadata = GIFMetadataExtractor::getMetadata( $filename );
+ } catch( Exception $e ) {
+ // Broken file?
+ wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
+ return '0';
+ }
+ }
+
+ return serialize($image->parsedGIFMetadata);
+
+ }
+
+ function formatMetadata( $image ) {
+ return false;
+ }
+
+ function getImageArea( $image, $width, $height ) {
+ $ser = $image->getMetadata();
+ if ($ser) {
+ $metadata = unserialize($ser);
+ return $width * $height * $metadata['frameCount'];
+ } else {
+ return $width * $height;
+ }
+ }
+
+ function getMetadataType( $image ) {
+ return 'parsed-gif';
+ }
+
+ function getLongDesc( $image ) {
+ global $wgUser, $wgLang;
+ $sk = $wgUser->getSkin();
+
+ $metadata = @unserialize($image->getMetadata());
+
+ if (!$metadata) return parent::getLongDesc( $image );
+
+ $info = array();
+ $info[] = $image->getMimeType();
+ $info[] = $sk->formatSize( $image->getSize() );
+
+ if ($metadata['looped'])
+ $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
+
+ if ($metadata['frameCount'] > 1)
+ $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
+
+ if ($metadata['duration'])
+ $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
+
+ $infoString = $wgLang->commaList( $info );
+
+ return "($infoString)";
+ }
+}