wp_get_default_extension_for_mime_type() WordPress Function
The wp_get_default_extension_for_mime_type() function allows you to get the default file extension for a given mime type. This is useful if you need to determine the file extension for a file that doesn't have one, or if you want to change the extension of a file.
wp_get_default_extension_for_mime_type( string $mime_type ) #
Returns first matched extension for the mime-type, as mapped from wp_get_mime_types().
Parameters
- $mime_type
(string)(Required)
Return
(string|false)
Source
File: wp-includes/functions.php
function wp_get_default_extension_for_mime_type( $mime_type ) { $extensions = explode( '|', array_search( $mime_type, wp_get_mime_types(), true ) ); if ( empty( $extensions[0] ) ) { return false; } return $extensions[0]; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.8.1 | Introduced. |