I've tried a few plugins to add mime types including the PJW Mime Config plugin. And adding this to a themes functions.php
file would work fine, too, for a non-WPMS site. But I need these to be allowable throughout the network.
So I've written my own plugin to do the trick. After looking at info from the codex as well several blog posts and this WPSE question. This is what I've come up with:
function new_mime_types($mimes) {
$mimes = array_merge($mimes, array(
'pdf' => 'application/pdf',
'zip' => 'multipart/x-zip'
//add your ext => mime to the array
//there are a LOT more, but to save space I've left the rest out :)
));
return $mimes;
}
// Hook
add_filter('upload_mimes', 'new_mime_types');
Now when I go to upload one of these file types, I receive a warning:
Warning: Cannot modify header information - headers already sent by (output started at [server]\wp-content\plugins\tps-mime-types.php:1) in [server]\wp-includes\pluggable.php on line 934.
I'm still new to WP, so any suggestions on what to do next?
Note: Also, I was going to tag this as upload-mimes and mime-types, but don't have the rep. :)
*// Update*
I've updated my plugin to the code below:
function new_mimes($mimes) {
// add your mime to the txt file below
// same formating and no spaces
// mime-types.txt file set up like this...
// pdf|application/pdf
// zip|multipart/x-zip
$file = "/tps-mime-types/mime-types.txt";
$contents = file_get_contents( plugins_url( $file ) );
$contents = str_replace( "\r", "|", $contents );
$contents = str_replace( "\n", "|", $contents );
$mime_types = explode( "|", $contents );
$counter=0;
foreach ( $mime_types as $ext_app ) {
if( !isset( $ext_app[0] ) ) $ext_app[0] = $ext_app[1];
$counter++;
}
// return the new full result
return $mimes;
}
add_filter('upload_mimes', 'new_mimes');
But after activating the plugin on a WPMS install I've had for a while as well as a single install, I'm still experiencing problems. Upon activation:
The plugin generated 3 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
Then when I attempt uploading a file matching one of the new mime-types I receive my original error message:
Warning: Cannot modify header information - headers already sent by (output started at [server]\wp-content\plugins\tps-mime-types\tps-mime-types.php:1) in [server]\wp-includes\pluggable.php on line 934
Any ideas?