r81601 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81600‎ | r81601 | r81602 >
Date:19:20, 6 February 2011
Author:btongminh
Status:ok
Tags:
Comment:
Files with a mime type that does not match the extension are now properly thumbnailed. Partial bug fix to bug 26661.
MediaHandler::getThumbType now checks if the extension and the mime type match. If they do not, a new extension is generated for the mime type. The rest of the thumbnailing code should then magically work.
Bonus: this also works with file names without extension, so might be a step closer to extension-less files.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/media/Generic.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/Generic.php
@@ -141,6 +141,18 @@
142142 * @return array thumbnail extension and MIME type
143143 */
144144 function getThumbType( $ext, $mime, $params = null ) {
 145+ $magic = MimeMagic::singleton();
 146+ if ( !$ext || $magic->isMatchingExtension( $ext, $mime ) === false ) {
 147+ // The extension is not valid for this mime type and we do
 148+ // recognize the mime type
 149+ $extensions = $magic->getExtensionsForType( $mime );
 150+ if ( $extensions ) {
 151+ return array( strtok( $extensions, ' ' ), $mime );
 152+ }
 153+ }
 154+
 155+ // The extension is correct (true) or the mime type is unknown to
 156+ // MediaWiki (null)
145157 return array( $ext, $mime );
146158 }
147159
Index: trunk/phase3/RELEASE-NOTES
@@ -119,6 +119,8 @@
120120 enabled, but user cannot see rc patrol links.
121121 * (bug 26548) ForeignAPIRepo (InstantCommons) now works with PDF files
122122 and other multi-paged file formats.
 123+* Files with a mime type that does not match the extension are now properly
 124+ thumbnailed
123125
124126 === API changes in 1.18 ===
125127 * (bug 26339) Throw warning when truncating an overlarge API result

Follow-up revisions

RevisionCommit summaryAuthorDate
r88078fixes bug 26661. getThumbType now checks mimetype in order to make sure only ...mglaser13:46, 14 May 2011

Status & tagging log