WordPress.org

Support

Support » Plugins and Hacks » Adding a new MIME type via the $override Array?

Adding a new MIME type via the $override Array?

  • Im just wanting some confirmation on how this works? I know i could just edit the admin-functions.php file and place my custom MIME type in there, but i wish to do it via the $override option for wp_handle_upload()

    My issuse is im not sure how im supose to declare it for the function? Is there a hook/action to do so?

    Any help would be great!

Viewing 2 replies - 1 through 2 (of 2 total)
  • There’s a few ways to add a mime type, and using $overrides is the difficult way. The only reason you’d use that is if you were writing a plugin or something that allowed the user to upload files and you were actually calling wp_handle_upload() yourself.

    The easiest way to add a mime type for everything else is to make use of the “upload_mimes” filter hook. You can do this in a plugin or in functions.php for your theme or whatever.

    Make a function like this:
    function add_my_mime_type($mimes)
    {
    ...
    }

    Then add the filter:
    add_filter('upload_mimes','add_my_mime_type');

    This will cause your function to get called and passed the $mimes array. Then you can just add your mime type to the array and return that array.

    arrrr great stuff, thats just what i was looking for i assumed there would be a hook or filter for it 🙂 thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding a new MIME type via the $override Array?’ is closed to new replies.