Spread the love

WordPress allows you to upload multiple file types to your website through the Media Library by default. This standard feature of WordPress is quite useful because it helps businesses and website administrators to establish themselves in a more pleasant manner. First, let us know the allowed file types and extensions in the WordPress Media library by default.

Documents & Sheets

  • .docx & .doc (Microsoft Word Document)
  • .pdf (Adobe: Portable Document Format)
  • .xlsx, .Xls (Microsoft Excel Document)
  • .pptx, .ppt, .pps, .ppsx (Microsoft Powerpoint File)
  • .odt (OpenDocument Text Documet)

Audio Files

  • .wav (WAVE Format)
  • .mp3 (MPEG3 Format)
  • .ogg (OGG Multimedia Container)
  • .m4a (Advanced Audio Coding)

Image Files

  • .jpeg & .jpg (Joint Photography Experts Group)
  • .psd (Adobe Photoshop Document)
  • .png (Portable Network Graphics)
  • .gif (Graphics interchange Product)
  • .ico (Icon File Extension)

Video Files

  • .wmv (Windows Media Video)
  • .mp4 (MPEG4 Format)
  • .m4v (Video Container Format)
  • .mov (Quick Time Format)
  • .avi (Audio Video Interleaved Format)
  • .ogv (OGG Vorbis Video Encoding)
  • .3gp (Mobile Phone Video)

If you want to upload a file type in your WordPress site not mentioned in the list above, you have reached the right place. Follow our instructions in the tutorial to know the techniques to add your desired file types and extensions.

Allowing Additional File types using wp-config.php

The simplest way to include all the file types into your WordPress site instead of the standard list of file types is to modify a small change in your wp-config.php file.

  1. Go to your WordPress Installed Directory
  2. Open wp-config.php in any of your favourite text editor
  3. Add the following code,
define ( ‘ALLOW_UNFILTERED_UPLOADS’ , true );
  1. Save the changes and upload the same file to your WordPress installed Directory

Before making changes in the wp-config.php file, make sure the security of your WordPress site is up to the mark because this wp-config.php is very crucial for the WordPress functioning and has the capacity to modify the nature of WordPress. In addition, take a backup of your wp-config.php file before making any changes. This could help you to restore your site back to normal if the result of your change is not as expected.

Allowing Additional File types using upload_mimes Filter:

In WordPress, you can create your own list of file types & extensions to be allowed into your site. This can be done by altering the $mime_types variable using upload_mimes filter available in WordPress. I have included an example to add and remove the list of file types to upload in your site.

Adding File type:

In this part we have included additional file types .waptt & .exo using $mime_types.

  1. Go to WordPress -> wp-content -> themes ->  YOUR-ACTIVE-THEME Directory
  2. Open functions.php in any of your favourite text editor
  3. Perform the modifications in the code as mentioned below as per your needs.
<?php

add_filter( 'upload_mimes', 'my_mime_types', 1, 1 );

function my_mime_types( $mime_types )

{
// Adding .waptt extension
$mime_types['waptt'] = 'audio/waptt';                 

// Adding .exo extension
$mime_types['exo'] = video/exo;                            

return $mime_types;

}
  1. Save the changes and upload the same file to your theme folder.

In the above code snippet, we have written a filter function to add more file types to the $mime_types array.

Removing File type

  1. Go to WordPress -> wp-content -> themes ->  YOUR-ACTIVE-THEME Directory
  2. Open functions.php in any of your favorite text editor
  3. Perform the modifications in the code as mentioned below as per your needs.
<?php

add_filter( 'upload_mimes', 'my_mime_types', 1, 1 );

function my_mime_types( $mime_types )

{

// Remove .doc extension
unset( $mime_types['doc'] );                                    

// Remove .docx extension
unset( $mime_types['docx'] );                                  

return $mime_types;

}
  1. Save the changes and upload the same file to your WordPress installed Directory

In the above code snippet, we are removing some of the accepted file types by using php unset function to remove ‘doc and ‘docx’ file types from the $mime_types array.

If you have any issues in uploading files with type mentioned in the standard list, contact your hosting provider to get the clarification as some of them restrict file types for their security & privacy concerns. Write to us your query about including additional file types in your WordPress. we would be happy to help.

Leave a Reply