How to Fix PNG Support in MediaWiki

by Marion Bates <mbates at>

Last modified: December 31 1969 16:00:00

  1. In LocalSettings.php, make sure that $wgEnableUploads is set to true and that "png" is in the $wgFileExtensions array:
    $wgEnableUploads       = true;
    $wgFileExtensions = array('png', 'jpg', 'jpeg','gif');
  2. Add these two lines to LocalSettings.php:
    $wgVerifyMimeType = false;
    $wgMimeDetectorCommand = "file -bi"; 
    (N.B. I think that the 2nd line probably does the trick by itself, but the first line was the first, partial solution I found, and seems to do no harm.)

  3. In /path/to/your/wiki/maintenance, edit rebuildImages.php and add these two lines at the top of the file (after the block of comments, preferably):
    $wgDBadminuser = "root";
    $wgDBadminpassword = "yourmysqlrootpassword";
  4. Run that script in php command line mode:
    php rebuildImages.php
    (If your system has no php command line binary, try finding and installing a "php-cli" package.)