How to Upload Flash f4v Video with WordPress

I had an issue with the WordPress 3.0+ video uploader while trying to upload Flash Video files with the extension f4v. Upon attempting to load a flash f4v video file with the WordPress video uploader the following error message would be thrown, “File type does not meet security guidelines.”. The ultimate fix is to add the filetype to the WordPress Accepted Filetypes.

What I did was to add the extension and mime type to the following functions in the WordPress functions.php file:

  • function wp_ext2type
  • function get_allowed_mime_types

The proper method for adding this Mime type would be to add via a Plugin so that any upgrades do not wipe out your changes. However, I was willing to deal with this, but reportedly the following plugin will help:

So, basically that’s it. That is how I added the mime type and extension information to allow the WordPress file/video uploader to successfully upload the Flash video type with extension f4v.

The following pages were helpful with this issue:

I’ve got an update to this post. I’m now adding this Flash f4v mime type to WordPress via my theme’s function.php file. It follows and adds to some of the links above explaining how to add a mime type to WordPress.  Most tutorials explaining how to add a mimi type to wordpress stop at the adding it to the function get_allowed_mime_types, this snippet adds the mime type to the wp_ext2type function as well:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
* Adds the f4v mime type
*/
// Add mimi types to function get_allowed_mime_types
function add_allowed_mime_types($mimes) {
    $my_new_mimes = array (
        'f4v' => 'video/mp4'
    );
    return array_merge($mimes,$my_new_mimes);
}
add_filter('upload_mimes','add_allowed_mime_types');
 
// Add an extension to (2) function wp_ext2type
function add_ext2_ext2type($ext) {
    $my_new_extensions = array (
        'video' => array( 'f4v' )
    );
    return array_merge($ext,$my_new_extensions);
}
add_filter('upload_mimes','add_ext2_ext2type');

Post written by Ed Reckers

Founder and lead web development consultant at Red Bridge Internet : San Francisco WordPress Developers and Consultants.

4 Responses to “How to Upload Flash f4v Video with WordPress”

  1. baltech

    Thanks for your given help ….by this i can easily upload flash video .:)

  2. Sampath

    Great Post. I added this to functions.php file on my theme. Also &gt should be >.

  3. ereckers

    Sampath, thanks for pointing out my formatting issue. Fixed.

  4. Ben Wolf

    I just fixed an issue on a website with a custom theme (for which ya’ll may have been the original developers) that used this exact code. The customers couldn’t create a new post because array( ‘f4v’ ) shouldn’t be an array. I removed array() from around ‘f4v’ and now it works.

Leave a Reply