Make WordPress Core

Changeset 34163


Ignore:
Timestamp:
09/15/2015 02:49:12 AM (10 years ago)
Author:
wonderboymusic
Message:

Don't ever use the guid value when retrieving URLs for media, use wp_get_attachment_url(). Use get_attached_file() for path to file.

Fixes #33386.

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/async-upload.php

    r34059 r34163  
    6363                echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
    6464            echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>';
    65             $title = $post->post_title ? $post->post_title : wp_basename( $post->guid ); // Title shouldn't ever be empty, but use filename just in case.
     65
     66            // Title shouldn't ever be empty, but use filename just in case.
     67            $file = get_attached_file( $post->ID );
     68            $title = $post->post_title ? $post->post_title : wp_basename( $file );
    6669            echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60, '&hellip;' ) ) . '</span></div>';
    6770            break;
  • trunk/src/wp-admin/custom-header.php

    r33854 r34163  
    11171117    final public function create_attachment_object( $cropped, $parent_attachment_id ) {
    11181118        $parent = get_post( $parent_attachment_id );
    1119         $parent_url = $parent->guid;
     1119        $parent_url = wp_get_attachment_url( $parent->ID );
    11201120        $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
    11211121
  • trunk/src/wp-admin/includes/ajax-actions.php

    r34161 r34163  
    31563156            $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
    31573157
    3158             $parent_url = get_post( $attachment_id )->guid;
     3158            $parent_url = wp_get_attachment_url( $attachment_id );
    31593159            $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
    31603160
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r34127 r34163  
    371371            <?php _media_states( $post ); ?>
    372372        </strong>
    373         <p class="filename"><span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span><?php echo wp_basename( $post->guid ); ?></p>
     373        <p class="filename">
     374            <span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span>
     375            <?php
     376            $file = get_attached_file( $post->ID );
     377            echo wp_basename( $file );
     378            ?>
     379        </p>
    374380        <?php
    375381    }
  • trunk/src/wp-admin/includes/class-wp-site-icon.php

    r33446 r34163  
    8181    public function create_attachment_object( $cropped, $parent_attachment_id ) {
    8282        $parent     = get_post( $parent_attachment_id );
    83         $parent_url = $parent->guid;
     83        $parent_url = wp_get_attachment_url( $parent->ID );
    8484        $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
    8585
  • trunk/src/wp-admin/includes/media.php

    r34003 r34163  
    13691369    $toggle_off = __( 'Hide' );
    13701370
    1371     $filename = esc_html( wp_basename( $post->guid ) );
     1371    $file = get_attached_file( $post->ID );
     1372    $filename = esc_html( wp_basename( $file ) );
    13721373    $title = esc_attr( $post->post_title );
    13731374
  • trunk/src/wp-includes/media.php

    r34134 r34163  
    11761176    <# } #>
    11771177    <div class="wp-playlist-caption">
    1178         <span class="wp-playlist-item-meta wp-playlist-item-title"><?php 
     1178        <span class="wp-playlist-item-meta wp-playlist-item-title"><?php
    11791179            /* translators: playlist item title */
    11801180            printf( _x( '&#8220;%s&#8221;', 'playlist item title' ), '{{ data.title }}' );
     
    20772077        return array();
    20782078
    2079     $filename = basename($attachment->guid);
     2079    $file = get_attached_file( $attachment->ID );
     2080    $filename = basename( $file );
    20802081
    20812082    $objects = array('attachment');
  • trunk/src/wp-includes/post-functions.php

    r34158 r34163  
    46494649        wp_delete_comment( $comment_id, true );
    46504650    }
    4651    
     4651
    46524652    wp_defer_comment_counting( false );
    46534653
     
    49754975            if ( $post = get_post( $mime ) ) {
    49764976                $post_id = (int) $post->ID;
    4977                 $ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid);
     4977                $file = get_attached_file( $post_id );
     4978                $ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $file);
    49784979                if ( !empty($ext) ) {
    49794980                    $post_mimes[] = $ext;
Note: See TracChangeset for help on using the changeset viewer.