Add duration field in query=imageinfo&iiprop=dimensions
authorBrian Wolff <bawolff+wn@gmail.com>
Sun, 31 Aug 2014 19:57:53 +0000 (16:57 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Thu, 18 Sep 2014 16:38:36 +0000 (13:38 -0300)
If the file has a duration (e.g. an audio or video file), include
it in the list of dimensions returned. Do not include anything
for still media (normal pictures).

This affects both query=imageinfo and TMH's query=videoinfo.

Bug: 55941
Change-Id: If172a1cbaca08bff2eb709f6c829985b28b0200d

includes/api/ApiQueryImageInfo.php

index 5cc1454..6178a51 100644 (file)
@@ -391,6 +391,13 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        if ( $pageCount !== false ) {
                                $vals['pagecount'] = $pageCount;
                        }
+
+                       // length as in how many seconds long a video is.
+                       $length = $file->getLength();
+                       if ( $length ) {
+                               // Call it duration, because "length" can be ambiguous.
+                               $vals['duration'] = (float)$length;
+                       }
                }
 
                $pcomment = isset( $prop['parsedcomment'] );
@@ -666,8 +673,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        'parsedcomment' =>  ' parsedcomment - Parse the comment on the version',
                        'canonicaltitle' => ' canonicaltitle - Adds the canonical title of the image file',
                        'url' =>            ' url           - Gives URL to the image and the description page',
-                       'size' =>           ' size          - Adds the size of the image in bytes ' .
-                               'and the height, width and page count (if applicable)',
+                       'size' =>           ' size          - Adds the size of the image in bytes, ' .
+                               'its height and its width. Page count and duration are added if applicable',
                        'dimensions' =>     ' dimensions    - Alias for size', // B/C with Allimages
                        'sha1' =>           ' sha1          - Adds SHA-1 hash for the image',
                        'mime' =>           ' mime          - Adds MIME type of the image',