From 0e81f311057e7be6ab5ebed6f1626110c74238b8 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Wed, 20 Oct 2010 14:50:30 +0000 Subject: [PATCH] Add support to upload WebP files. Disabled by default and no thumbnailing support. Relates to bug 25397 --- RELEASE-NOTES | 1 + includes/MimeMagic.php | 7 +++++++ includes/mime.info | 1 + includes/mime.types | 1 + 4 files changed, 10 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index cd30cd91ac..c89ede5bc3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -181,6 +181,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN for versioning * Maintenance scripts get a --memory-limit option to override defaults (which is usually to set it to -1 to disable the limit) +* (bug 25397) Allow uploading (not displaying) of WebP images, disabled by default === Bug fixes in 1.17 === * (bug 17560) Half-broken deletion moved image files to deletion archive diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index d86012c351..7d7fedd06a 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -402,6 +402,7 @@ class MimeMagic { // Formats we recognize magic numbers for 'djvu', 'ogx', 'ogg', 'ogv', 'oga', 'spx', 'mid', 'pdf', 'wmf', 'xcf', 'webm', 'mkv', 'mka', + 'webp', // XML formats we sure hope we recognize reliably 'svg', @@ -548,6 +549,12 @@ class MimeMagic { return "unknown/unknown"; } + /* Look for WebP */ + if( strncmp( $head, "RIFF", 4 ) == 0 && strncmp( substr( $head, 8, 8), "WEBPVP8 ", 8 ) == 0 ) { + wfDebug( __METHOD__ . ": recognized file as image/webp\n" ); + return "image/webp"; + } + /* * Look for PHP. Check for this before HTML/XML... Warning: this is a * heuristic, and won't match a file with a lot of non-PHP before. It diff --git a/includes/mime.info b/includes/mime.info index 4999d81f29..3a32f5d972 100644 --- a/includes/mime.info +++ b/includes/mime.info @@ -19,6 +19,7 @@ image/x-portable-graymap image/x-portable-greymap [BITMAP] image/x-bmp image/x-ms-bmp image/bmp application/x-bmp application/bmp [BITMAP] image/x-photoshop image/psd image/x-psd image/photoshop [BITMAP] image/vnd.djvu image/x.djvu image/x-djvu [BITMAP] +image/webp [BITMAP] image/svg+xml application/svg+xml application/svg image/svg [DRAWING] application/postscript [DRAWING] diff --git a/includes/mime.types b/includes/mime.types index 4171d28dbb..bf8c6dd170 100644 --- a/includes/mime.types +++ b/includes/mime.types @@ -85,6 +85,7 @@ image/svg+xml svg image/tiff tiff tif image/vnd.djvu djvu djv image/vnd.wap.wbmp wbmp +image/webp webp image/x-cmu-raster ras image/x-icon ico image/x-ms-bmp bmp -- 2.20.1