WordPress at a glance

get_the_post_thumbnail_url() WP 1.0

Return the post thumbnail URL.

Возвращает

String/false. Post thumbnail URL or false if no URL is available.

1 time = 0.001901s = very slow | 50000 times = 18s = slow | PHP 7.0.5, WP 4.4.2

No Hooks.

Usage

get_the_post_thumbnail_url( $post, $size );
$post(int/WP_Post)
Post ID or WP_Post object.
Default: global $post
$size(string/array)
Registered image size to retrieve the source for or a flat array of height and width dimensions.
Default: 'post-thumbnail'

Список изменений

С версии 4.4.0 Введена.

Code of get_the_post_thumbnail_url() WP 5.5.1

wp-includes/post-thumbnail-template.php
<?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;
	}

	return wp_get_attachment_image_url( $post_thumbnail_id, $size );
}

Related Functions

From tag: Thumbnail (images)

More from category: Thumbnails

No comments
    Log In . Register