I am trying to include the new WP Media Uploader in a Custom Meta Box.
I found this tutorial.
However, I am looking for a way to limit the uploader to only accept certain types of files like ‘application/msword’, ‘application/vnd.ms-excel’, ‘application/pdf’, etc. and to return the linked document url to a text field i have in the metabox
Any ideas, links or just basically anything to point me in the right direction would be highly appreciated!
The file types that you have specified ‘application/msword’, ‘application/vnd.ms-excel’, ‘application/pdf’ are already supported by media uploader.
To see the default supported mime file types, call wp_get_mime_types() function.
Use upload_mimes filter as shown in following code to make media uploader to accept files types other than the default.
Add following code in your themes functions.php file
Like Vinod Dalvi said, you could use the filter upload_mimes to achieve what you need.
You can deregister existing mimes types using
and adding new type by adding then to the array :
for instance
This is taken from here
You say :
Do you mean limiting mime type only for one type of uploader ? I can’t see the logic involved, since if there are other “instances” of media uploader, “forbidden” media types could be uploaded anyway.