From 84d8b18bd9e929b6f655a90351485dfaff16ddbb Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sun, 31 Aug 2014 16:57:53 -0300 Subject: [PATCH] Add duration field in query=imageinfo&iiprop=dimensions 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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 5cc1454046..6178a51900 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -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', -- 2.20.1