get_the_post_thumbnail_url
函数
get_the_post_thumbnail_url ( $post = null, $size = 'post-thumbnail' )
- 参数
-
-
(int|WP_Post)
$post
Optional. Post ID or WP_Post object. Default is global `$post`.- Required: 否
- Default: null
-
(string|int[])
$size
Optional. Registered image size to retrieve the source for or a flat array of height and width dimensions. Default ‘post-thumbnail’.- Required: 否
- Default: ‘post-thumbnail’
-
(int|WP_Post)
- 返回值
-
- (string|false) Post thumbnail URL or false if no image is available. If `$size` does not match any registered image size, the original image URL will be returned.
- 定义位置
-
-
wp-includes/post-thumbnail-template.php
, line 246
-
wp-includes/post-thumbnail-template.php
- 引入
- 4.4.0
- 弃用
- –
Returns the post thumbnail URL.
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 ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。