Media: Replace `basename()` usage on media upload screen with `wp_basename()` for better multibyte filenames support.
Includes minor code layout fixes for better readability. Follow-up to [44785], [51023]. See #51754. Built from https://develop.svn.wordpress.org/trunk@51030 git-svn-id: http://core.svn.wordpress.org/trunk@50639 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bd192a0fbc
commit
b1666e78fb
|
@ -48,22 +48,27 @@ if ( isset( $_REQUEST['attachment_id'] ) && (int) $_REQUEST['attachment_id'] &&
|
|||
|
||||
switch ( $_REQUEST['fetch'] ) {
|
||||
case 3:
|
||||
echo '<div class="attachment-details">';
|
||||
$thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true );
|
||||
if ( $thumb_url ) {
|
||||
echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
|
||||
}
|
||||
// Title shouldn't ever be empty, but use filename just in case.
|
||||
$file = get_attached_file( $post->ID );
|
||||
$fileurl = wp_get_attachment_url( $post->ID );
|
||||
$title = $post->post_title ? $post->post_title : wp_basename( $file );
|
||||
|
||||
echo '<div class="filename new"><span class="media-list-title"><strong>' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . '</strong></span> <span class="media-list-subtitle">' . basename( $file ) . '</span></div>';
|
||||
echo '</div>';
|
||||
?>
|
||||
<div class="attachment-details">
|
||||
<?php
|
||||
$thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true );
|
||||
if ( $thumb_url ) {
|
||||
echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
|
||||
}
|
||||
|
||||
// Title shouldn't ever be empty, but use filename just in case.
|
||||
$file = get_attached_file( $post->ID );
|
||||
$file_url = wp_get_attachment_url( $post->ID );
|
||||
$title = $post->post_title ? $post->post_title : wp_basename( $file );
|
||||
?>
|
||||
<div class="filename new">
|
||||
<span class="media-list-title"><strong><?php echo esc_html( wp_html_excerpt( $title, 60, '…' ) ); ?></strong></span>
|
||||
<span class="media-list-subtitle"><?php echo wp_basename( $file ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="attachment-tools">
|
||||
<span class="media-item-copy-container copy-to-clipboard-container edit-attachment">
|
||||
<button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $fileurl; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button>
|
||||
<button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $file_url; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button>
|
||||
<span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
|
||||
</span>
|
||||
<?php
|
||||
|
|
|
@ -139,11 +139,11 @@
|
|||
}
|
||||
|
||||
.media-item button .copy-attachment-url {
|
||||
margin-top:14px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.media-item .copy-to-clipboard-container {
|
||||
margin-top:7px;
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
.media-item .describe-toggle-off,
|
||||
|
|
|
@ -138,11 +138,11 @@
|
|||
}
|
||||
|
||||
.media-item button .copy-attachment-url {
|
||||
margin-top:14px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.media-item .copy-to-clipboard-container {
|
||||
margin-top:7px;
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
.media-item .describe-toggle-off,
|
||||
|
|
|
@ -372,10 +372,12 @@ function wpFileExtensionError( up, file, message ) {
|
|||
*/
|
||||
function copyAttachmentUploadURLClipboard() {
|
||||
var clipboard = new ClipboardJS( '.copy-attachment-url' ),
|
||||
successTimeout;
|
||||
successTimeout;
|
||||
|
||||
clipboard.on( 'success', function( event ) {
|
||||
var triggerElement = jQuery( event.trigger ),
|
||||
successElement = jQuery( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) );
|
||||
|
||||
// Clear the selection and move focus back to the trigger.
|
||||
event.clearSelection();
|
||||
// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-51029';
|
||||
$wp_version = '5.8-alpha-51030';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue