WordPress.org

Make WordPress Core

Changeset 51030


Ignore:
Timestamp:
05/26/2021 02:23:11 PM (4 months ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/vendor/plupload/handlers.js

    r51023 r51030  
    373373function copyAttachmentUploadURLClipboard() {
    374374    var clipboard = new ClipboardJS( '.copy-attachment-url' ),
    375     successTimeout;
     375        successTimeout;
     376
    376377    clipboard.on( 'success', function( event ) {
    377378        var triggerElement = jQuery( event.trigger ),
    378379            successElement = jQuery( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) );
     380
    379381        // Clear the selection and move focus back to the trigger.
    380382        event.clearSelection();
  • trunk/src/wp-admin/async-upload.php

    r51023 r51030  
    4949    switch ( $_REQUEST['fetch'] ) {
    5050        case 3:
    51             echo '<div class="attachment-details">';
    52             $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true );
    53             if ( $thumb_url ) {
    54                 echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
    55             }
    56             // Title shouldn't ever be empty, but use filename just in case.
    57             $file    = get_attached_file( $post->ID );
    58             $fileurl = wp_get_attachment_url( $post->ID );
    59             $title   = $post->post_title ? $post->post_title : wp_basename( $file );
     51            ?>
     52            <div class="attachment-details">
     53                <?php
     54                $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true );
     55                if ( $thumb_url ) {
     56                    echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
     57                }
    6058
    61             echo '<div class="filename new"><span class="media-list-title"><strong>' . esc_html( wp_html_excerpt( $title, 60, '&hellip;' ) ) . '</strong></span> <span class="media-list-subtitle">' . basename( $file ) . '</span></div>';
    62             echo '</div>';
    63             ?>
     59                // Title shouldn't ever be empty, but use filename just in case.
     60                $file     = get_attached_file( $post->ID );
     61                $file_url = wp_get_attachment_url( $post->ID );
     62                $title    = $post->post_title ? $post->post_title : wp_basename( $file );
     63                ?>
     64                <div class="filename new">
     65                    <span class="media-list-title"><strong><?php echo esc_html( wp_html_excerpt( $title, 60, '&hellip;' ) ); ?></strong></span>
     66                    <span class="media-list-subtitle"><?php echo wp_basename( $file ); ?></span>
     67                </div>
     68            </div>
    6469            <div class="attachment-tools">
    6570                <span class="media-item-copy-container copy-to-clipboard-container edit-attachment">
    66                     <button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $fileurl; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button>
     71                    <button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $file_url; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button>
    6772                    <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
    6873                </span>
  • trunk/src/wp-admin/css/media.css

    r51023 r51030  
    139139
    140140.media-item button .copy-attachment-url {
    141     margin-top:14px;
     141    margin-top: 14px;
    142142}
    143143
    144144.media-item .copy-to-clipboard-container {
    145     margin-top:7px;
     145    margin-top: 7px;
    146146}
    147147
Note: See TracChangeset for help on using the changeset viewer.