r67616 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67615‎ | r67616 | r67617 >
Date:12:40, 8 June 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
* (bug 23835) Need "thumbmime" result in "imageinfo" query
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryImageInfo.php
@@ -222,6 +222,11 @@
223223 $vals['thumbwidth'] = intval( $file->getWidth() );
224224 $vals['thumbheight'] = intval( $file->getHeight() );
225225 }
 226+
 227+ if ( isset( $prop['thumbmime'] ) ) {
 228+ $thumbFile = UnregisteredLocalFile::newFromPath( $mto->getPath(), false );
 229+ $vals['thumbmime'] = $thumbFile->getMimeType();
 230+ }
226231 }
227232 }
228233 $vals['url'] = $file->getFullURL();
@@ -319,6 +324,7 @@
320325 'dimensions', // For backwards compatibility with Allimages
321326 'sha1',
322327 'mime',
 328+ 'thumbmime',
323329 'metadata',
324330 'archivename',
325331 'bitdepth',
Index: trunk/phase3/RELEASE-NOTES
@@ -212,6 +212,7 @@
213213 similar to prop=categories's clcategorie
214214 * (bug 23834) Invalid "thumbwidth" and "thumbheight" in "imageinfo" query when
215215 thumbnailing larger than original image
 216+* (bug 23835) Need "thumbmime" result in "imageinfo" query
216217
217218 === Languages updated in 1.17 ===
218219

Comments

#Comment by Bryan (talk | contribs)   09:34, 18 June 2010

Won't this fail for wikis which use a 404 handler to generate thumbnails?

#Comment by Reedy (talk | contribs)   11:08, 18 June 2010

I've no idea. Can you provide an example?

#Comment by Bryan (talk | contribs)   11:18, 18 June 2010

Just looked a bit more careful at the code and it does not appear to be a problem. $file->transform will not actually generate a thumbnail, but only a link to where the thumbnail is supposed to be. The thumbnail may or may not exist already depending on whether it was previously requested. The 404 handler will create the thumbnail only when it is actually requested. UnregisteredLocalFile::getMimeType will eventually call MimeMagic::guestMimeType. There is a lot of magic in there that tries to guess the MIME type from the file contents, but it looks like it will handle a non-existent file properly.

Still is there no way to get the MIME type from the MediaTransformOutput directly?

#Comment by Reedy (talk | contribs)   11:38, 18 June 2010

Doesn't seem to be.

http://svn.wikimedia.org/doc/classMediaTransformOutput.html has nothing...

Unless we were to add it

#Comment by Bryan (talk | contribs)   13:02, 18 June 2010

It is apparently defined in the ImageHandler. $file->getHandler()->getThumbType() should do the trick.

#Comment by Reedy (talk | contribs)   17:38, 20 June 2010
00142         function getThumbType( $ext, $mime ) {
00143                 return array( $ext, $mime );
00144         }

for

$file->getHandler()->getThumbType();

We need to pass it stuff, but that's a MediaTransformOutput, which is limited. And as per the bug, the extension, and hence mime might not be the same as the original

Status & tagging log