1

WordPress has list of allowed Media Library upload extensions in wp-includes/functions.php but is there any way to return them to theme's files as an array?

2
  • Are you using multisite? – shea Dec 4 '12 at 11:03
  • 1
    No. But an option to have both WP and WPMU solutions as an answer to this question would be great :) – Paul Dec 4 '12 at 11:10
2

get_allowed_mime_types() function returns an array of mime types keyed by the file extension regex corresponding to those types.

1

I believe you're looking for the wp_get_mime_types() function

3
  • 1
    This function is introduced in WP3.5 and is not available in current stable release 3.4.x. – Parham Dec 4 '12 at 11:39
  • @Parham Thanks - I wasn't aware of this. Do you know if this function will be preferred over get_allowed_mime_types() when 3.5 is released? – shea Dec 4 '12 at 11:43
  • 2
    according to the source code, wp_get_mime_types() returns the list of ALL mime types and applies the 'mime_types' filter on the list. The filter should be used to add types, not remove them. get_allowed_mime_types() returns a list of allowed mime types, it uses wp_get_mime_types() to fetch the list but applies one more filter: 'upload_mimes' which can be used to remove types. – Parham Dec 4 '12 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.