Adding a new MIME type via the $override Array? (3 posts)

  1. Phunky
    Posted 10 years ago #

    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!

  2. 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:

    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.

  3. Phunky
    Posted 10 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.