• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

WP Thinker

The WordPress Playground

  • Snippets
  • Best
  • Guides
  • Reviews
Home / Wordpress

October 22, 2018 Muhammed Swalih

How to Add Additional File Types to be Uploaded to WordPress

How to Add Additional File Types to be Uploaded to WordPress

For some security reasons, WordPress only allows uploading some particular file formats of files. The commonly allowed formats are image files, audio files, video files, PDF, Microsoft Office or OpenOffice documents, etc… Any other types of files will be blocked if you try to upload them to the media library. Though, you can’t upload any other formats of files to use on your website. You don’t like limitations, and we also don’t. So, we prepared this article on How to add additional file types to be uploaded to WordPress. In this article, we are sharing the method to get any of the file types as you like in your website. So, let’s give a look.

Which file types are allowed by WordPress by default?

WordPress limited the allowed file types to a few numbers. You can upload image files, audio files, video files, PDF, Microsoft Office or OpenOffice documents, etc… to the WordPress. You will be blocked from uploading other types of files to your WordPress. Below is a screenshot of an error message, while trying to upload an unsupported file type.

not-allowed-file-type-in-wordpress

  • Find the full list of allowed file types in WordPress

How to Add Additional File Types to be Uploaded to WordPress

WordPress is an entirely tweakable platform. The custom codes can always help you to fulfill your needs. WordPress blocked the certain file types due to some security reasons. It doesn’t mean, you can’t upload other formats. You can simply edit some codes and easily access the permission to add new file types that can be uploaded to the WordPress website. Use the following code in your functions.php file to add an exception to the .svg files.

function my_myme_types($mime_types){
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);

The ‘svg’ will be replaced by the extension of the file you want to add. The file extension is the key in $mime_types associated array, and the mime type goes as its value. SVG file extension represents files with the mime type image/svg+xml in this example.

  • Find out more about mime types

If you want to add multiple extensions at the same time, use the code given below.

function my_myme_types($mime_types){
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
$mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files
return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);

Now, you will be able to upload the specified file formats without any restrictions or blocks.

Muhammed Swalih

A WordPress expert who has been tweaking WordPress functions, plugins, themes and almost everything related to WordPress for the past 5+ years.

Primary Sidebar

Related Articles

Footer

WP Thinker is a website that publishes everything related to WordPress, Plugins, Themes, SEO, Blogging, etc.

  • Facebook
  • Twitter
  • Pinterest

Copyright © 2022 · WP Thinker

  • About Us
  • Advertise
  • Write for Us
  • Privacy Policy
  • Terms and Conditions
  • Contact Us
This website uses cookies to serve you better. By continuing to use this website, you agree to our cookie and Privacy Policy.