How to Upload Banned File Types to WordPress Media Library

How to Upload Banned File Types to WordPress Media Library

WordPress only allows you to upload a few types of files to its Media Library.

Here are the default list of file types that you can upload to the Media Library.

.jpg/.jpeg (images)
.png (images)
.gif (images)
.pdf (documents)
.doc/.docx/.odt (documents)
.ppt/.pptx/.pps/.ppsx (presentations)
.xls/.xlsx (spreadsheets)
.mp3/.m4a/.ogg/.wav (audio)
.mp4/.m4v/.mov/.wmv/.avi/.mpg/.ogv/.3gp/.3g2 (video)

How Can I Upload Other File Types To Media Library?

You can add your own allowable extension types for uploading to the WordPress Media Library with a little code nippet.

Here’s the PHP code to allow .WebP images to be uploaded to WordPress.

/**
 * Add extra mime types to the media manager
 *
 * @param $existing_mimes
 * @return mixed
 */
function zpd_media_manager_add_mime_types( $existing_mimes ){
    $existing_mimes['webp'] = 'image/webp';

    return $existing_mimes;
}
add_filter( 'mime_types', 'zpd_media_manager_add_mime_types' );

You can add as many types as you need to as long as you know the file mime type.

Place the code in your child theme’s functions.php file.

Was this article helpful?
YesNo