Title: wp_ext2type
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_ext2type( string $ext ): string|void

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#wp--skip-link--target)

Retrieves the file type based on the extension name.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#parameters)󠁿

 `$ext`stringrequired

The extension to search.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#return)󠁿

 string|void The file type, example: audio, video, document, spreadsheet, etc.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#source)󠁿

    ```php
    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;
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L3000)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L3000-L3009)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_ext_types()](https://developer.wordpress.org/reference/functions/wp_get_ext_types/)`wp-includes/functions.php` |

Retrieves the list of common file extensions and their types.

  |

| Used by | Description | 
| [wp_media_upload_handler()](https://developer.wordpress.org/reference/functions/wp_media_upload_handler/)`wp-admin/includes/media.php` |

Handles the process of uploading media.

  | 
| [wp_ajax_send_link_to_editor()](https://developer.wordpress.org/reference/functions/wp_ajax_send_link_to_editor/)`wp-admin/includes/ajax-actions.php` |

Handles sending a link to the editor via AJAX.

  | 
| [wp_mime_type_icon()](https://developer.wordpress.org/reference/functions/wp_mime_type_icon/)`wp-includes/post.php` |

Retrieves the icon for a MIME type or attachment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_ext2type/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_ext2type%2F)
before being able to contribute a note or feedback.