wp_check_filetype_and_ext
Filters the "real" file type of the given file.
Usage
add_filter( 'wp_check_filetype_and_ext', 'wp_kama_check_filetype_and_ext_filter', 10, 5 );
/**
* Function for `wp_check_filetype_and_ext` filter-hook.
*
* @param array $wp_check_filetype_and_ext Values for the extension, mime type, and corrected filename.
* @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.
*
* @return array
*/
function wp_kama_check_filetype_and_ext_filter( $wp_check_filetype_and_ext, $file, $filename, $mimes, $real_mime ){
// filter...
return $wp_check_filetype_and_ext;
}
- $wp_check_filetype_and_ext(array)
Values for the extension, mime type, and corrected filename.
-
ext(string|false)
File extension, or false if the file doesn't match a mime type. -
type(string|false)
File mime type, or false if the file doesn't match a mime type. - proper_filename(string|false)
File name with its correct extension, or false if it cannot be determined.
-
- $file(string)
- Full path to the file.
- $filename(string)
- The name of the file (may differ from $file due to $file being in a tmp directory).
- $mimes(string[]|null)
- Array of mime types keyed by their file extension regex, or null if none were provided.
- $real_mime(string|false)
- The actual mime type or false if the type cannot be determined.
Changelog
| Since 3.0.0 | Introduced. |
| Since 5.1.0 | The $real_mime parameter was added. |
Where the hook is called
wp_check_filetype_and_ext
wp-includes/functions.php 3319
return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime );