mime file type validation on wiki

Viewed 138

I am running a private MediaWiki version 1.35.1 on Ubuntu Mate. I added a new file extension, 'cev', to my LocalSettings.php but when I try to upload a file it gives me this message:

enter image description here

So, I went to this page and down under Mime Type validation it says there are 2 files in the Mediawiki includes folder that can be customized to allow/ignore that error. Well, a "broken link" note on that page seems to indicate that the file MimeMap.php under /includes/libs/mime is the one to modify.

So, how do i modify MimeMap.php so it either ignores .CEV files or otherwise accepts them without the error message?

2 Answers

To support extra mime types for uploads on your wiki, you can use the MimeMagicInit hook since MediaWiki 1.24.

For example, to recognise .md files as text/plain for Markdown:

// Recognise the extension
$wgHooks['MimeMagicInit'][] = function ( MimeAnalyzer $mime ) {
    $mime->addExtraTypes( 'text/plain md' );
};

// Allow it for new uploads
$wgFileExtensions[] = 'md';

I've also updated the MIME type detection page on mediawiki.org with this, and more information.

Related