wp_ext2type

函式
wp_ext2type ( $ext )
引數
  • (string) $ext The extension to search.
    Required:
返回值
  • (string|void) The file type, example: audio, video, document, spreadsheet, etc.
定義位置
相關方法
wp_get_ext_typeswp_get_mime_typeswp_get_httpwp_titlewp_exif_date2ts
引入
2.5.0
棄用
-

wp_ext2type: 這個函式用來將副檔名轉換為MIME型別。MIME型別用於識別被提供的檔案的型別,如文字檔案或影象檔案: 這個函式對於確保向使用者提供檔案時使用正確的MIME型別很有用。

根據副檔名檢索檔案型別。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
}
}
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; } } }
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;
		}
	}
}

常見問題

FAQs
檢視更多 >