Make WordPress Core


Ignore:
Timestamp:
10/19/2020 08:27:34 PM (4 years ago)
Author:
antpb
Message:

Media: Add 'Uploaded to' for individual media items in the media editor.
Adds a link in the media editor showing which post a media item was uploaded to.
Props karmatosed, garrett-eclipse, Mista-Flo, SergeyBiryukov, joemcgill, hellofromTonya.
Fixes #46866.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/media.php

    r49198 r49207  
    32893289    $att_url = wp_get_attachment_url( $attachment_id );
    32903290
    3291     ?>
     3291    $author = get_userdata( $post->post_author );
     3292
     3293    $uploaded_by_name = __( '(no author)' );
     3294    $uploaded_by_link = '';
     3295    if ( $author->exists() ) {
     3296        $uploaded_by_name = $author->display_name ? $author->display_name : $author->nickname;
     3297        $uploaded_by_link = get_edit_user_link( $author->ID );
     3298    } ?>
     3299    <div class="misc-pub-section misc-pub-uploadedby">
     3300        <?php if ( $uploaded_by_link ) : ?>
     3301            <?php _e( 'Uploaded by:' ); ?> <a href="<?php echo $uploaded_by_link ?>"><strong><?php echo $uploaded_by_name ?></strong></a>
     3302        <?php else: ?>
     3303            <?php _e( 'Uploaded by:' ); ?> <strong><?php echo $uploaded_by_name ?></strong>
     3304        <?php endif; ?>
     3305    </div>
     3306
     3307    <?php if ( $post->post_parent ) :
     3308        $post_parent = get_post( $post->post_parent );
     3309        if ( $post_parent ) :
     3310            $uploaded_to_title = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
     3311            $uploaded_to_link = get_edit_post_link( $post->post_parent, 'raw' ); ?>
     3312            <div class="misc-pub-section misc-pub-uploadedto">
     3313                <?php if ( $uploaded_to_link ) : ?>
     3314                    <?php _e( 'Uploaded to:' ); ?> <a href="<?php echo $uploaded_to_link ?>"><strong><?php echo $uploaded_to_title; ?></strong></a>
     3315                <?php else: ?>
     3316                    <?php _e( 'Uploaded to:' ); ?> <strong><?php echo $uploaded_to_title; ?></strong>
     3317                <?php endif; ?>
     3318            </div>
     3319        <?php endif; ?>
     3320    <?php endif; ?>
     3321
    32923322    <div class="misc-pub-section misc-pub-attachment">
    32933323        <label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
Note: See TracChangeset for help on using the changeset viewer.