Our Technology Services wiki is powered by MediaWiki—the same software that powers Wikipedia. So far, most things have worked relatively well for us. Even a few upgrades have gone pretty smoothly.
The problem
However, when we moved to a new server last week, we were stuck with a puzzling problem. Any images in PNG format that were uploaded to our wiki weren’t being properly resized for thumbnails. After some investigation, it looked like MediaWiki wasn’t recognizing the newly uploaded PNG files as images—it thought their MIME types were all text/plain
instead of image/png
.
We finally pinpointed the source of the problem today. Apparently, MediaWiki uses a PHP extension called mime magic to identify MIME types (which appears to be deprecated in favor of the Fileinfo extension). Upon running a quick phpinfo()
, we found the location of the “magic file” and cracked it open for a peek. We scrolled through the code and noticed that there were definitions for all sorts of other file types, including GIFs and JPEGs, but nothing for PNG files.
The fix
So, based on the definition for GIF images in our magic file, we added the following lines to the images section of our magic file:
# PNG images
1 string PNG image/png
Saved, restarted apache, tried the upload again, and everything worked like a dream. Hopefully this can help you out if you encounter a similar issue.
Leave a Reply