Filter hook 'wp_check_filetype_and_ext'

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

View Source

wp_check_filetype_and_ext

Filter Hook
Description
Filters the "real" file type of the given file. }

Hook Information

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

Hook Parameters

Type Name Description
array $wp_check_filetype_and_ext { Values for the extension, mime type, and corrected filename.
string $file Full path to the file.
string $filename The name of the file (may differ from $file due to $file being in a tmp directory).
string[]|null $mimes Array of mime types keyed by their file extension regex, or null if none were provided.
string|false $real_mime The actual mime type or false if the type cannot be determined.

Usage Examples

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

function my_custom_filter($wp_check_filetype_and_ext, $file, $filename, $mimes, $real_mime) {
    // Your custom filtering logic here
    return $wp_check_filetype_and_ext;
}

Source Code Context

wp-includes/functions.php:3314 - How this hook is used in WordPress core
<?php
3309  	 *                                                 $file being in a tmp directory).
3310  	 * @param string[]|null $mimes                     Array of mime types keyed by their file extension regex, or null if
3311  	 *                                                 none were provided.
3312  	 * @param string|false  $real_mime                 The actual mime type or false if the type cannot be determined.
3313  	 */
3314  	return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime );
3315  }
3316  
3317  /**
3318   * Returns the real mime type of an image file.
3319   *

PHP Documentation

<?php
/**
	 * Filters the "real" file type of the given file.
	 *
	 * @since 3.0.0
	 * @since 5.1.0 The $real_mime parameter was added.
	 *
	 * @param array         $wp_check_filetype_and_ext {
	 *     Values for the extension, mime type, and corrected filename.
	 *
	 *     @type string|false $ext             File extension, or false if the file doesn't match a mime type.
	 *     @type string|false $type            File mime type, or false if the file doesn't match a mime type.
	 *     @type string|false $proper_filename File name with its correct extension, or false if it cannot be determined.
	 * }
	 * @param string        $file                      Full path to the file.
	 * @param string        $filename                  The name of the file (may differ from $file due to
	 *                                                 $file being in a tmp directory).
	 * @param string[]|null $mimes                     Array of mime types keyed by their file extension regex, or null if
	 *                                                 none were provided.
	 * @param string|false  $real_mime                 The actual mime type or false if the type cannot be determined.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 5
  • File: wp-includes/functions.php
Related Hooks

Related hooks will be displayed here in future updates.