On this page
wp_ext2type( string $ext ): string|void
Retrieves the file type based on the extension name.
Parameters
$extstring Required-
The extension to search.
Return
string|void The file type, example: audio, video, document, spreadsheet, etc.
Source
File: wp-includes/functions.php. View all references
function wp_ext2type( $ext ) {
$ext = strtolower( $ext );
$ext2type = wp_get_ext_types();
foreach ( $ext2type as $type => $exts ) {
if ( in_array( $ext, $exts, true ) ) {
return $type;
}
}
}
Related
Uses
| Uses | Description |
|---|---|
| wp_get_ext_types() wp-includes/functions.php | Retrieves the list of common file extensions and their types. |
Used By
| Used By | Description |
|---|---|
| wp_media_upload_handler() wp-admin/includes/media.php | Handles the process of uploading media. |
| wp_ajax_send_link_to_editor() wp-admin/includes/ajax-actions.php | Ajax handler for sending a link to the editor. |
| wp_mime_type_icon() wp-includes/post.php | Retrieves the icon for a MIME type or attachment. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_ext2type