From d7f99f31e6835b2826c309a264e48b6f4c659d39 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 26 May 2021 14:23:11 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@51030 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/vendor/plupload/handlers.js | 4 ++- src/wp-admin/async-upload.php | 31 ++++++++++++-------- src/wp-admin/css/media.css | 4 +-- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/js/_enqueues/vendor/plupload/handlers.js b/src/js/_enqueues/vendor/plupload/handlers.js index aaf1519aff..7958e7231d 100644 --- a/src/js/_enqueues/vendor/plupload/handlers.js +++ b/src/js/_enqueues/vendor/plupload/handlers.js @@ -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 diff --git a/src/wp-admin/async-upload.php b/src/wp-admin/async-upload.php index 9c0190a198..6e04e0a19a 100644 --- a/src/wp-admin/async-upload.php +++ b/src/wp-admin/async-upload.php @@ -48,22 +48,27 @@ if ( isset( $_REQUEST['attachment_id'] ) && (int) $_REQUEST['attachment_id'] && switch ( $_REQUEST['fetch'] ) { case 3: - echo '
'; - $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ); - if ( $thumb_url ) { - echo ''; - } - // 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 '
' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . ' ' . basename( $file ) . '
'; - echo '
'; ?> +
+ '; + } + + // 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 ); + ?> +
+ + +
+
- +