返回介绍

wp_get_attachment_thumb_file()

发布于 2017-09-11 11:59:45 字数 2065 浏览 918 评论 0 收藏 0

wp_get_attachment_thumb_file( int $post_id )

Retrieve thumbnail for an attachment.


description


参数

$post_id

(int) (Optional) Attachment ID. Default 0.


返回值

(string|false) False on failure. Thumbnail file path on success.


源代码

File: wp-includes/post.php

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) ) {
		/**
		 * Filters 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;
}

更新日志

Versiondescription
2.1.0Introduced.

相关函数

Uses

  • wp-includes/plugin.php: apply_filters()
  • wp-includes/post.php: wp_get_attachment_metadata()
  • wp-includes/post.php: wp_get_attachment_thumb_file
  • wp-includes/post.php: get_post()
  • wp-includes/post.php: get_attached_file()

Used By

  • wp-includes/media.php: image_downsize()
  • wp-includes/post.php: wp_get_attachment_thumb_url()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文