Update get_the_post_thumbnail_url() so it returns false on failure, to bring it inline with wp_get_attachment_image_url(). Correct and introduce new tests.

Fixes #33070

Built from https://develop.svn.wordpress.org/trunk@34663


git-svn-id: http://core.svn.wordpress.org/trunk@34627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-09-28 15:34:25 +00:00
parent 14c9ea88ea
commit 2a8abfef81
2 changed files with 10 additions and 4 deletions

View File

@ -182,8 +182,11 @@ function get_the_post_thumbnail( $post = null, $size = 'post-thumbnail', $attr =
* @return string|false Post thumbnail URL or false if no URL is available.
*/
function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) {
$image = wp_get_attachment_image_url( get_post_thumbnail_id( $post ), $size );
return isset( $image ) ? $image : false;
$post_thumbnail_id = get_post_thumbnail_id( $post );
if ( ! $post_thumbnail_id ) {
return false;
}
return wp_get_attachment_image_url( $post_thumbnail_id, $size );
}
/**
@ -195,5 +198,8 @@ function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) {
* array of height and width dimensions. Default 'post-thumbnail'.
*/
function the_post_thumbnail_url( $size = 'post-thumbnail' ) {
echo get_the_post_thumbnail_url( null, $size );
$url = get_the_post_thumbnail_url( null, $size );
if ( $url ) {
echo esc_url( $url );
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34662';
$wp_version = '4.4-alpha-34663';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.