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.

Built from https://develop.svn.wordpress.org/trunk@49207


git-svn-id: http://core.svn.wordpress.org/trunk@48969 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
antpb 2020-10-19 20:29:05 +00:00
parent fbc1622741
commit 9556c08b35
8 changed files with 90 additions and 34 deletions

View File

@ -459,6 +459,8 @@ form#tags-filter {
#post-body .misc-pub-post-status:before,
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-uploadedby:before,
#post-body .misc-pub-uploadedto:before,
#post-body .misc-pub-revisions:before,
#post-body .misc-pub-response-to:before,
#post-body .misc-pub-comment-status:before {
@ -468,6 +470,8 @@ form#tags-filter {
#post-body .misc-pub-post-status:before,
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-uploadedby:before,
#post-body .misc-pub-uploadedto:before,
#post-body .misc-pub-revisions:before,
#post-body .misc-pub-response-to:before,
#post-body .misc-pub-comment-status:before {
@ -496,6 +500,18 @@ form#tags-filter {
top: -1px;
}
#post-body .misc-pub-uploadedby:before {
content: "\f110";
position: relative;
top: -1px;
}
#post-body .misc-pub-uploadedto:before {
content: "\f318";
position: relative;
top: -1px;
}
#post-body .misc-pub-revisions:before {
content: "\f321";
}

File diff suppressed because one or more lines are too long

View File

@ -458,6 +458,8 @@ form#tags-filter {
#post-body .misc-pub-post-status:before,
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-uploadedby:before,
#post-body .misc-pub-uploadedto:before,
#post-body .misc-pub-revisions:before,
#post-body .misc-pub-response-to:before,
#post-body .misc-pub-comment-status:before {
@ -467,6 +469,8 @@ form#tags-filter {
#post-body .misc-pub-post-status:before,
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-uploadedby:before,
#post-body .misc-pub-uploadedto:before,
#post-body .misc-pub-revisions:before,
#post-body .misc-pub-response-to:before,
#post-body .misc-pub-comment-status:before {
@ -495,6 +499,18 @@ form#tags-filter {
top: -1px;
}
#post-body .misc-pub-uploadedby:before {
content: "\f110";
position: relative;
top: -1px;
}
#post-body .misc-pub-uploadedto:before {
content: "\f318";
position: relative;
top: -1px;
}
#post-body .misc-pub-revisions:before {
content: "\f321";
}

File diff suppressed because one or more lines are too long

View File

@ -3288,7 +3288,37 @@ function attachment_submitbox_metadata() {
$att_url = wp_get_attachment_url( $attachment_id );
?>
$author = get_userdata( $post->post_author );
$uploaded_by_name = __( '(no author)' );
$uploaded_by_link = '';
if ( $author->exists() ) {
$uploaded_by_name = $author->display_name ? $author->display_name : $author->nickname;
$uploaded_by_link = get_edit_user_link( $author->ID );
} ?>
<div class="misc-pub-section misc-pub-uploadedby">
<?php if ( $uploaded_by_link ) : ?>
<?php _e( 'Uploaded by:' ); ?> <a href="<?php echo $uploaded_by_link ?>"><strong><?php echo $uploaded_by_name ?></strong></a>
<?php else: ?>
<?php _e( 'Uploaded by:' ); ?> <strong><?php echo $uploaded_by_name ?></strong>
<?php endif; ?>
</div>
<?php if ( $post->post_parent ) :
$post_parent = get_post( $post->post_parent );
if ( $post_parent ) :
$uploaded_to_title = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
$uploaded_to_link = get_edit_post_link( $post->post_parent, 'raw' ); ?>
<div class="misc-pub-section misc-pub-uploadedto">
<?php if ( $uploaded_to_link ) : ?>
<?php _e( 'Uploaded to:' ); ?> <a href="<?php echo $uploaded_to_link ?>"><strong><?php echo $uploaded_to_title; ?></strong></a>
<?php else: ?>
<?php _e( 'Uploaded to:' ); ?> <strong><?php echo $uploaded_to_title; ?></strong>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="misc-pub-section misc-pub-attachment">
<label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" id="attachment_url" value="<?php echo esc_attr( $att_url ); ?>" />

View File

@ -405,10 +405,27 @@ function wp_print_media_templates() {
</span>
<div class="details">
<h2 class="screen-reader-text"><?php _e( 'Details' ); ?></h2>
<div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div>
<div class="filename"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div>
<div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div>
<div class="uploaded-by">
<strong><?php _e( 'Uploaded by:' ); ?></strong>
<# if ( data.authorLink ) { #>
<a href="{{ data.authorLink }}">{{ data.authorName }}</a>
<# } else { #>
{{ data.authorName }}
<# } #>
</div>
<# if ( data.uploadedToTitle ) { #>
<div class="uploaded-to">
<strong><?php _e( 'Uploaded to:' ); ?></strong>
<# if ( data.uploadedToLink ) { #>
<a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a>
<# } else { #>
{{ data.uploadedToTitle }}
<# } #>
</div>
<# } #>
<div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div>
<div class="file-type"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div>
<div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div>
<# if ( 'image' === data.type && ! data.uploading ) { #>
<# if ( data.width && data.height ) { #>
@ -485,20 +502,6 @@ function wp_print_media_templates() {
<label for="attachment-details-two-column-description" class="name"><?php _e( 'Description' ); ?></label>
<textarea id="attachment-details-two-column-description" {{ maybeReadOnly }}>{{ data.description }}</textarea>
</span>
<span class="setting">
<span class="name"><?php _e( 'Uploaded By' ); ?></span>
<span class="value">{{ data.authorName }}</span>
</span>
<# if ( data.uploadedToTitle ) { #>
<span class="setting">
<span class="name"><?php _e( 'Uploaded To' ); ?></span>
<# if ( data.uploadedToLink ) { #>
<span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
<# } else { #>
<span class="value">{{ data.uploadedToTitle }}</span>
<# } #>
</span>
<# } #>
<span class="setting" data-setting="url">
<label for="attachment-details-two-column-copy-link" class="name"><?php _e( 'File URL:' ); ?></label>
<input type="text" class="attachment-details-copy-link" id="attachment-details-two-column-copy-link" value="{{ data.url }}" readonly />

View File

@ -3809,26 +3809,17 @@ function wp_prepare_attachment_for_js( $attachment ) {
$author = new WP_User( $attachment->post_author );
if ( $author->exists() ) {
$response['authorName'] = html_entity_decode( $author->display_name, ENT_QUOTES, get_bloginfo( 'charset' ) );
$response['authorName'] = html_entity_decode( $author->display_name ? $author->display_name : $author->nickname, ENT_QUOTES, get_bloginfo( 'charset' ) );
$response['authorLink'] = get_edit_user_link( $author->ID );
} else {
$response['authorName'] = __( '(no author)' );
}
if ( $attachment->post_parent ) {
$post_parent = get_post( $attachment->post_parent );
} else {
$post_parent = false;
}
if ( $post_parent ) {
$parent_type = get_post_type_object( $post_parent->post_type );
if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $attachment->post_parent ) ) {
$response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
}
if ( $parent_type && current_user_can( 'read_post', $attachment->post_parent ) ) {
if ( $post_parent ) {
$response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
$response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
}
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-49206';
$wp_version = '5.6-alpha-49207';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.