get_the_post_thumbnail_url
( int|WP_Post $post = null, string|int[] $size = 'post-thumbnail' )获得文章缩略图URL。get_the_post_thumbnail_url函数参数
$post(int|WP_Post) (Optional)文章ID or WP_Post 对象. 缺省值是全局变量 $post,缺省值为空。
$size
(string|int[]) (Optional)取回册图像的由高度和宽度尺寸组成的数组。缺省值是'post-thumbnail'。
get_the_post_thumbnail_url函数返回值
(string|false) 缩略图的URL,如果没有图像可用则返回false。如果$size与任何注册的图像大小不匹配,则将返回原始图像URL。get_the_post_thumbnail_url函数源文件
wp-includes/post-thumbnail-template.php
function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) {
$post_thumbnail_id = get_post_thumbnail_id( $post );
if ( ! $post_thumbnail_id ) {
return false;
}
$thumbnail_url = wp_get_attachment_image_url( $post_thumbnail_id, $size );
/**
* Filters the post thumbnail URL.
*
* @since 5.9.0
*
* @param string|false $thumbnail_url Post thumbnail URL or false if the post does not exist.
* @param int|WP_Post|null $post Post ID or WP_Post object. Default is global `$post`.
* @param string|int[] $size Registered image size to retrieve the source for or a flat array
* of height and width dimensions. Default 'post-thumbnail'.
*/
return apply_filters( 'post_thumbnail_url', $thumbnail_url, $post, $size );
}
以上就是青锋建站给大家分享的wordpress获取缩略图url函数get_the_post_thumbnail_url的使用方法,
青锋建站承接网站建设服务,包括织梦建站,phpcms建站,wordpress建站,CMS系统开发,SEO网站优化,网络营销推广,企业邮箱,400电话。转载请注明来源网址:青锋建站-http://www.sjzphp.com/cmsxitong/wordpressxt/get_the_post_thumbnail_url.html