check_upload_mimes() WordPress Function

The check_upload_mimes() function is used to check if a given file is allowed to be uploaded to WordPress. This function is used by the upload_mimes filter.

check_upload_mimes( array $mimes ) #

Checks an array of MIME types against a list of allowed types.


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 filetypes allowed provided by Multisite Super Admins at wp-admin/network/settings.php.


Top ↑

Parameters

$mimes

(array)(Required)


Top ↑

Return

(array)


Top ↑

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 && false !== strpos( $ext_pattern, $ext ) ) {
				$site_mimes[ $ext_pattern ] = $mime;
			}
		}
	}
	return $site_mimes;
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More