简介
获取当前文章的缩略图(Post Thumbnail)。
用法
参数
$post_id
(integer) (Optional) 文章 ID。
Default: 当前文章 ID
$size
(string/array) (Optional) 图片大小,可以是以下几个关键字:thumbnail, medium, large, full,或者通过函数
PLEASE NOTE: The crop does not work in WP 3.0+. All that is needed for WP 3.0+ is the call for the thumbnail to post. Then proceed to media in the dashboard and set your thumbnail to crop to the size you wish to use.
$attr
(array) (Optional) 属性/值的一个数组,the_post_thumbnail 传递给函数
$default_attr = array(
'src'=> $src,
'class'=> "attachment-$size",
'alt'=> trim(strip_tags( $wp_postmeta->_wp_attachment_image_alt )),
'title'=> trim(strip_tags( $attachment->post_title )),
);
返回值
(string)
返回缩略图的 HTML 代码。
修改记录
Since 2.9.0
源文件
wp-includes/post-thumbnail-template.php