Ticket #15447: 15447.3.diff

File 15447.3.diff, 1.7 KB (added by scribu, 2 years ago)

Remove extra caching key

  • wp-includes/post-thumbnail-template.php

     
    4848} 
    4949 
    5050/** 
     51 * Update cache for thumbnails in current loop 
     52 * 
     53 * @since 3.2 
     54 */ 
     55function update_thumbnail_cache() { 
     56        global $wp_query; 
     57 
     58        // return if not at loop start 
     59        if ( 0 != $wp_query->current_post ) 
     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 
     79/** 
    5180 * Retrieve Post Thumbnail. 
    5281 * 
    5382 * @since 2.9.0 
     
    5786 * @param string|array $attr Optional. Query string or array of attributes. 
    5887 */ 
    5988function get_the_post_thumbnail( $post_id = null, $size = 'post-thumbnail', $attr = '' ) { 
     89        if ( in_the_loop() ) 
     90                update_thumbnail_cache(); 
     91 
    6092        $post_id = ( null === $post_id ) ? get_the_ID() : $post_id; 
    6193        $post_thumbnail_id = get_post_thumbnail_id( $post_id ); 
    6294        $size = apply_filters( 'post_thumbnail_size', $size ); 
    6395        if ( $post_thumbnail_id ) { 
    6496                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 
     97 
    6598                $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr ); 
    6699                do_action( 'end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); 
    67100        } else {