Make WordPress Core

Ticket #37343: 37343.2.diff

File 37343.2.diff, 1.1 KB (added by wonderboymusic, 9 years ago)
  • src/wp-includes/post-template.php

     
    14451445function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
    14461446        $_post = get_post( $id );
    14471447
    1448         if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
     1448        if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) {
    14491449                return __( 'Missing Attachment' );
     1450        }
    14501451
    1451         if ( $permalink )
     1452        if ( $permalink ) {
    14521453                $url = get_attachment_link( $_post->ID );
     1454        }
    14531455
    14541456        if ( $text ) {
    14551457                $link_text = $text;
     
    14591461                $link_text = '';
    14601462        }
    14611463
    1462         if ( trim( $link_text ) == '' )
     1464        if ( '' === trim( $link_text ) ) {
    14631465                $link_text = $_post->post_title;
     1466        }
    14641467
     1468        if ( '' === trim( $link_text ) ) {
     1469                $link_text = esc_html( pathinfo( get_attached_file( $_post->ID ), PATHINFO_FILENAME ) );
     1470        }
    14651471        /**
    14661472         * Filters a retrieved attachment page link.
    14671473         *