X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/bf5c68485ef07868ad0a91168ecd0092af7661ae..refs/tags/wordpress-3.4:/wp-includes/post-thumbnail-template.php diff --git a/wp-includes/post-thumbnail-template.php b/wp-includes/post-thumbnail-template.php index 65a51726..16952d03 100644 --- a/wp-includes/post-thumbnail-template.php +++ b/wp-includes/post-thumbnail-template.php @@ -39,7 +39,7 @@ function get_post_thumbnail_id( $post_id = null ) { * * @since 2.9.0 * - * @param int $size Optional. Image size. Defaults to 'post-thumbnail', which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );. + * @param int $size Optional. Image size. Defaults to 'post-thumbnail', which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );. * @param string|array $attr Optional. Query string or array of attributes. */ function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) { @@ -50,9 +50,12 @@ function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) { * Update cache for thumbnails in the current loop * * @since 3.2 + * + * @param object $wp_query Optional. A WP_Query instance. Defaults to the $wp_query global. */ -function update_post_thumbnail_cache() { - global $wp_query; +function update_post_thumbnail_cache( $wp_query = null ) { + if ( ! $wp_query ) + $wp_query = $GLOBALS['wp_query']; if ( $wp_query->thumbnails_cached ) return; @@ -64,13 +67,7 @@ function update_post_thumbnail_cache() { } if ( ! empty ( $thumb_ids ) ) { - get_posts( array( - 'update_post_term_cache' => false, - 'include' => $thumb_ids, - 'post_type' => 'attachment', - 'post_status' => 'inherit', - 'nopaging' => true - ) ); + _prime_post_caches( $thumb_ids, false, true ); } $wp_query->thumbnails_cached = true; @@ -82,7 +79,7 @@ function update_post_thumbnail_cache() { * @since 2.9.0 * * @param int $post_id Optional. Post ID. - * @param string $size Optional. Image size. Defaults to 'thumbnail'. + * @param string $size Optional. Image size. Defaults to 'post-thumbnail'. * @param string|array $attr Optional. Query string or array of attributes. */ function get_the_post_thumbnail( $post_id = null, $size = 'post-thumbnail', $attr = '' ) { @@ -100,5 +97,3 @@ function get_the_post_thumbnail( $post_id = null, $size = 'post-thumbnail', $att } return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr ); } - -?>