Filter hook 'mime_types'

in WP Core File wp-includes/functions.php at line 3442

View Source

mime_types

Filter Hook
Description
Filters the list of mime types and file extensions. This filter should be used to add, not remove, mime types. To remove mime types, use the {@see 'upload_mimes'} filter.

Hook Information

File Location wp-includes/functions.php View on GitHub
Hook Type Filter
Line Number 3442

Hook Parameters

Type Name Description
string[] $wp_get_mime_types Mime types keyed by the file extension regex corresponding to those types.

Usage Examples

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

function my_custom_filter($wp_get_mime_types) {
    // Your custom filtering logic here
    return $wp_get_mime_types;
}

Source Code Context

wp-includes/functions.php:3442 - How this hook is used in WordPress core
<?php
3437  	 * @since 3.5.0
3438  	 *
3439  	 * @param string[] $wp_get_mime_types Mime types keyed by the file extension regex
3440  	 *                                    corresponding to those types.
3441  	 */
3442  	return apply_filters(
3443  		'mime_types',
3444  		array(
3445  			// Image formats.
3446  			'jpg|jpeg|jpe'                 => 'image/jpeg',
3447  			'gif'                          => 'image/gif',

PHP Documentation

<?php
/**
	 * Filters the list of mime types and file extensions.
	 *
	 * This filter should be used to add, not remove, mime types. To remove
	 * mime types, use the {@see 'upload_mimes'} filter.
	 *
	 * @since 3.5.0
	 *
	 * @param string[] $wp_get_mime_types Mime types keyed by the file extension regex
	 *                                    corresponding to those types.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/functions.php
Related Hooks

Related hooks will be displayed here in future updates.