Plugin Planet

Premium WordPress Plugins

This quick tutorial explains how to enable uploads for file types that are not supported by WordPress by default. As explained in this tutorial, USP Pro supports all of the file types that are supported by WordPress. And as you can see in that post, that’s a LOT of different file formats. But not every file type is on the list, for example 3GP files. Fortunately, enabling support is pretty simple. Read on to learn how..

Important! Before allowing new file types, make sure that it is safe to do so. I.e., do not allow your users to upload unsafe file types.

Support Additional File Types

To support file types that are not supported by default, add the following code to your theme’s functions.php file:

// USP Pro - Enable File Types
function usp_enable_file_types($existing_mimes) {
	
	$existing_mimes['3gp'] = 'text/3gp';
	$existing_mimes['swf'] = 'text/swf';

	return $existing_mimes;
	
}
add_filter('upload_mimes', 'usp_enable_file_types');

Here we are adding support for two file types: 3gp and swf. You can edit the code as needed to add more file types, or remove either of the example types.

Or, if you would rather use a custom plugin instead of adding to functions.php, you can create a new blank PHP file, and add the following code (add to the beginning of the file):

<?php 
/*
	Plugin Name:  USP Pro - Enable File Types
	Plugin URI:   https://plugin-planet.com/usp-pro/
	Description:  Enables uploading of additional file type(s) with USP Pro.
	Author URI:   https://plugin-planet.com/
	Author:       Jeff Starr
	Version:      1.0
	License:      GPL v2 or later
*/

if (!defined('ABSPATH')) die();

function usp_enable_file_types($existing_mimes) {
	
	$existing_mimes['3gp'] = 'text/3gp';
	$existing_mimes['swf'] = 'text/swf';
	
	return $existing_mimes;
	
}
add_filter('upload_mimes', 'usp_enable_file_types');

Bam! Instant plugin. You can upload to the /plugins/ directory like other plugins, or upload to /mu-plugins/ and call it done.