WordPress.org

Make WordPress Core

Ticket #11571: 11571.3.diff

File 11571.3.diff, 983 bytes (added by leewillis77, 8 years ago)

Revised patch updated against trunk, plus few minor changes

  • post-thumbnail-template.php

     
    102102        return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );
    103103}
    104104
     105/**
     106 * Retrieve Post Thumbnail URL
     107 *
     108 * @param int $post_id Optional. Post ID.
     109 * @param string $size Optional. Image size.  Defaults to 'post-thumbnail'.
     110 */
     111function get_the_post_thumbnail_src( $post_id = null, $size = 'post-thumbnail' ) {
     112        $post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
     113        $post_thumbnail_id = get_post_thumbnail_id( $post_id );
     114
     115        if ( $post_thumbnail_id ) {
     116                if ( in_the_loop() )
     117                        update_post_thumbnail_cache();
     118                $size = apply_filters( 'post_thumbnail_size', $size );
     119                list( $src ) = wp_get_attachment_image_src( $post_thumbnail_id, $size, false );
     120        } else {
     121                $src = FALSE;
     122        }
     123        return $src;
     124}
     125
    105126?>