WordPress.org

Make WordPress Core

Ticket #11571: 11571.6.diff

File 11571.6.diff, 1.8 KB (added by leewillis77, 4 years ago)

Adds filters as per scribu's comments

  • post-thumbnail-template.php

     
    8383 * @since 2.9.0 
    8484 * 
    8585 * @param int $post_id Optional. Post ID. 
    86  * @param string $size Optional. Image size.  Defaults to 'thumbnail'. 
     86 * @param string $size Optional. Image size.  Defaults to 'post-thumbnail'. 
    8787 * @param string|array $attr Optional. Query string or array of attributes. 
    8888 */ 
    8989function get_the_post_thumbnail( $post_id = null, $size = 'post-thumbnail', $attr = '' ) { 
    90         $post_id = ( null === $post_id ) ? get_the_ID() : $post_id; 
    9190        $post_thumbnail_id = get_post_thumbnail_id( $post_id ); 
    9291        $size = apply_filters( 'post_thumbnail_size', $size ); 
    9392        if ( $post_thumbnail_id ) { 
     
    102101        return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr ); 
    103102} 
    104103 
     104/** 
     105 * Retrieve Post Thumbnail URL 
     106 * 
     107 * @param int $post_id Optional. Post ID. 
     108 * @param string $size Optional. Image size.  Defaults to 'post-thumbnail'. 
     109 * @return string|bool Image src, or false if the post does not have a thumbnail. 
     110 */ 
     111function get_the_post_thumbnail_src( $post_id = null, $size = 'post-thumbnail' ) { 
     112        $post_thumbnail_id = get_post_thumbnail_id( $post_id ); 
     113 
     114        if ( ! $post_thumbnail_id ) { 
     115                return false; 
     116 
     117        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 
     118        if ( in_the_loop() ) 
     119                update_post_thumbnail_cache(); 
     120        $size = apply_filters( 'post_thumbnail_size', $size ); 
     121        list( $src ) = wp_get_attachment_image_src( $post_thumbnail_id, $size, false ); 
     122        do_action( 'end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); 
     123 
     124        return $src; 
     125} 
     126 
    105127?>