Ticket #15447: 15447.4.diff
File 15447.4.diff, 1.5 KB (added by , 10 years ago) |
---|
-
wp-includes/post-thumbnail-template.php
48 48 } 49 49 50 50 /** 51 * Update cache for thumbnails in current loop 52 * 53 * @since 3.2 54 */ 55 function update_thumbnail_cache() { 56 global $wp_query; 57 58 // do this only once per loop 59 if ( $wp_query->_thumbnails_cached ) 60 return; 61 62 $thumb_ids = array(); 63 foreach ( $wp_query->posts as $post ) { 64 if ( $id = get_post_thumbnail_id( $post->ID ) ) 65 $thumb_ids[] = $id; 66 } 67 68 if ( ! empty( $thumb_ids ) ) { 69 get_posts( array( 70 'update_post_term_cache' => false, 71 'include' => $thumb_ids, 72 'post_type' => 'attachment', 73 'post_status' => 'inherit', 74 'nopaging' => true, 75 ) ); 76 } 77 78 $wp_query->_thumbnails_cached = true; 79 } 80 81 /** 51 82 * Retrieve Post Thumbnail. 52 83 * 53 84 * @since 2.9.0 … … 62 93 $size = apply_filters( 'post_thumbnail_size', $size ); 63 94 if ( $post_thumbnail_id ) { 64 95 do_action( 'begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters 96 97 if ( in_the_loop() ) 98 update_thumbnail_cache(); 99 65 100 $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr ); 66 101 do_action( 'end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); 67 102 } else {