Filter hook 'wp_prevent_unsupported_mime_type_uploads'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php at line 150

View Source

wp_prevent_unsupported_mime_type_uploads

Filter Hook
Description
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.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php View on GitHub
Hook Type Filter
Line Number 150

Hook Parameters

Type Name Description
bool $check_mime Whether to prevent uploads of unsupported image types.
string|null $mime_type The mime type of the file being uploaded (if available).

Usage Examples

Basic Usage
<?php
// Hook into wp_prevent_unsupported_mime_type_uploads
add_filter('wp_prevent_unsupported_mime_type_uploads', 'my_custom_filter', 10, 2);

function my_custom_filter($check_mime, $mime_type) {
    // Your custom filtering logic here
    return $check_mime;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php:150 - How this hook is used in WordPress core
<?php
 145  		 * @since 6.8.0
 146  		 *
 147  		 * @param bool        $check_mime Whether to prevent uploads of unsupported image types.
 148  		 * @param string|null $mime_type  The mime type of the file being uploaded (if available).
 149  		 */
 150  		$prevent_unsupported_uploads = apply_filters( 'wp_prevent_unsupported_mime_type_uploads', true, isset( $files['file']['type'] ) ? $files['file']['type'] : null );
 151  
 152  		// If the upload is an image, check if the server can handle the mime type.
 153  		if (
 154  			$prevent_unsupported_uploads &&
 155  			isset( $files['file']['type'] ) &&

PHP Documentation

<?php
/**
		 * 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.
		 *
		 * @since 6.8.0
		 *
		 * @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).
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
Related Hooks

Related hooks will be displayed here in future updates.