wp_prevent_unsupported_mime_type_uploads filter-hookWP 6.8.0

Filter whether the server should prevent uploads for image types it doesn't support. Default true.

Developers can use this filter to enable uploads of certain image types. By default image types that are not supported by the server are prevented from being uploaded.

Usage

add_filter( 'wp_prevent_unsupported_mime_type_uploads', 'wp_kama_prevent_unsupported_mime_type_uploads_filter', 10, 2 );

/**
 * Function for `wp_prevent_unsupported_mime_type_uploads` filter-hook.
 * 
 * @param bool        $check_mime Whether to prevent uploads of unsupported image types.
 * @param string|null $mime_type  The mime type of the file being uploaded (if available).
 *
 * @return bool
 */
function wp_kama_prevent_unsupported_mime_type_uploads_filter( $check_mime, $mime_type ){

	// filter...
	return $check_mime;
}
$check_mime(true|false)
Whether to prevent uploads of unsupported image types.
$mime_type(string|null)
The mime type of the file being uploaded (if available).

Changelog

Since 6.8.0 Introduced.

Where the hook is called

WP_REST_Attachments_Controller::create_item_permissions_check()
wp_prevent_unsupported_mime_type_uploads
media_upload_form()
wp_prevent_unsupported_mime_type_uploads
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 150
$prevent_unsupported_uploads = apply_filters( 'wp_prevent_unsupported_mime_type_uploads', true, isset( $files['file']['type'] ) ? $files['file']['type'] : null );
wp-admin/includes/media.php 2198
$prevent_unsupported_uploads = apply_filters( 'wp_prevent_unsupported_mime_type_uploads', true, null );

Where the hook is used in WordPress

Usage not found.