X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FGIF.php;h=5f23855c81128a2e0b0b2978be221a4c4632aa5b;hb=010410265a5505b44a273bb119d8fac7f1fa7739;hp=94aca615ae7fcce102121b4da8d254718fa97023;hpb=3368cccde53732c1278f51632e69b9865c4ee6ba;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/GIF.php b/includes/media/GIF.php index 94aca615ae..5f23855c81 100644 --- a/includes/media/GIF.php +++ b/includes/media/GIF.php @@ -65,11 +65,11 @@ class GIFHandler extends BitmapHandler { $meta = $image->getMetadata(); if ( !$meta ) { - return array(); + return []; } $meta = unserialize( $meta ); if ( !isset( $meta['metadata'] ) ) { - return array(); + return []; } unset( $meta['metadata']['_MW_GIF_VERSION'] ); @@ -170,7 +170,7 @@ class GIFHandler extends BitmapHandler { } /* Preserve original image info string, but strip the last char ')' so we can add even more */ - $info = array(); + $info = []; $info[] = $original; if ( $metadata['looped'] ) { @@ -187,4 +187,25 @@ class GIFHandler extends BitmapHandler { return $wgLang->commaList( $info ); } + + /** + * Return the duration of the GIF file. + * + * Shown in the &query=imageinfo&iiprop=size api query. + * + * @param File $file + * @return float The duration of the file. + */ + public function getLength( $file ) { + $serMeta = $file->getMetadata(); + MediaWiki\suppressWarnings(); + $metadata = unserialize( $serMeta ); + MediaWiki\restoreWarnings(); + + if ( !$metadata || !isset( $metadata['duration'] ) || !$metadata['duration'] ) { + return 0.0; + } else { + return (float)$metadata['duration']; + } + } }