check_upload_mimes( array $mimes )
Check an array of MIME types against a whitelist.
Description Description
WordPress ships with a set of allowed upload filetypes, which is defined in wp-includes/functions.php in get_allowed_mime_types(). This function is used to filter that list against the filetype whitelist provided by Multisite Super Admins at wp-admin/network/settings.php.
Parameters Parameters
- $mimes
-
(array) (Required)
Return Return
(array)
Source Source
File: wp-includes/ms-functions.php
function check_upload_mimes( $mimes ) {
$site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );
$site_mimes = array();
foreach ( $site_exts as $ext ) {
foreach ( $mimes as $ext_pattern => $mime ) {
if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) {
$site_mimes[ $ext_pattern ] = $mime;
}
}
}
return $site_mimes;
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Get allowed MIME types
$mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'php' => 'application/x-php', // This isn't on the whitelist! ); $mimes = check_upload_mimes( $mimes ); print_r( $mimes );Output: