Allowing More File Extension Uploads in WordPress

On a site I recently helped get up and running, I wanted to upload a pgp key.  Doing so naturally was impossible, as pgp isn’t in the default approved list of file extensions.  All of my research on the matter told me to go to:  While this may solve the problem, it seemed like more work than was necessary.  I mean, all I want to do is add one item to the list!

Well, in searching around, I found this function in the wp-includes/functions.php file:

function get_allowed_mime_types() {
        static $mimes = false;

        if ( !$mimes ) {
                // Accepted MIME types are set here as PCRE unless provided.
                $mimes = apply_filters( 'upload_mimes', array(
                'jpg|jpeg|jpe' => 'image/jpeg',
                'gif' => 'image/gif',
...(Line 2547)

In this list, you can simply add whatever extension you want, and the MIME type (google that). Much simpler than adding a function and doing the round about way!

Image Source:

Comments are closed