wp_get_attachment_thumb_file()
wp_get_attachment_thumb_file( int $post_id ) 检索附件的缩略图。 …
wp_get_attachment_thumb_file( int $post_id )
检索附件的缩略图。
Retrieve thumbnail for an attachment.
检索附件的缩略图。
Retrieve thumbnail for an attachment.
目录锚点:#参数#源码
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $post_id | (int) | 附件ID。默认为0。 |
源码(Source)
/**
* Retrieve thumbnail for an attachment.
*
* @since 2.1.0
*
* @param int $post_id Optional. Attachment ID. Default 0.
* @return string|false False on failure. Thumbnail file path on success.
*/
function wp_get_attachment_thumb_file( $post_id = 0 ) {
$post_id = (int) $post_id;
if ( !$post = get_post( $post_id ) )
return false;
if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
return false;
$file = get_attached_file( $post->ID );
if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) {
/**
* Filter the attachment thumbnail file path.
*
* @since 2.1.0
*
* @param string $thumbfile File path to the attachment thumbnail.
* @param int $post_id Attachment ID.
*/
return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
}
return false;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.1.0 | wp-includes/post.php | 20 | 20 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!