描述:
通过id判断一篇文章是否为图片附件
用法:
<?php wp_attachment_is_image( $post_id ); ?>
参数:
$post_id
(int) (可选) ID
默认值: 0
源文件:
/**
* Checks if the attachment is an image.
*
* @since 2.1.0
* @since 4.2.0 Modified into wrapper for wp_attachment_is() and
* allowed WP_Post object to be passed.
*
* @param int|WP_Post $post Optional. Attachment ID. Default 0.
* @return bool Whether the attachment is an image.
*/
function wp_attachment_is_image( $post = 0 ) {
return wp_attachment_is( 'image', $post );
}