WordPress获取附件MIME类型函数:get_post_mime_type - 利剑分享-科技生活-利剑分享-科技生活
利剑分享-科技生活-利剑分享-科技生活
利剑分享-科技生活

WordPress获取附件MIME类型函数:get_post_mime_type

WordPress获取附件MIME类型函数:get_post_mime_type

WordPress函数get_post_mime_type主要用于获取附件的MIME类型,当然也能返回文章、页面的MIME类型,但在实际应用中这并没有什么用处。

get_post_mime_type( int $ID )

函数参数

$ID

整数型,默认为空

文章、附件的ID

函数使用示例

$type = get_post_mime_type($post_id);switch ($type) {case 'image/jpeg':case 'image/png':case 'image/gif':return $base . "image.png"; break;case 'video/mpeg':case 'video/mp4': case 'video/quicktime':return $base . "video.png"; break;case 'text/csv':case 'text/plain': case 'text/xml':return $base . "text.png"; break;default:return $base . "file.png";}

扩展阅读

get_post_mime_type()函数位于:wp-includes/post.php

相关函数:

  • wp_check_filetype()

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'uos_print_tracking_script' not found or invalid function name in /www/wwwroot/flybace.com/wp-includes/class-wp-hook.php on line 324