根据扩展名检索文件类型。
原型
wp_ext2type( string $ext )
参数
$ext
(string)
(Required)
搜索的扩展名。
返回值
(string|void)
文件类型,例如:音频,视频,文档,电子表格等。
源文件
路径:wp-includes/functions.php
<?php
...
function wp_ext2type( $ext ) {
$ext = strtolower( $ext );
$ext2type = wp_get_ext_types();
foreach ( $ext2type as $type => $exts )
if ( in_array( $ext, $exts ) )
return $type;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_ext2type/