Make WordPress Core


Ignore:
Timestamp:
03/31/2014 05:15:39 AM (13 years ago)
Author:
wonderboymusic
Message:

Cleanup up the display, escaping, and handling of ID3 data for media. Rename wp_get_relevant_id3_keys() to wp_get_attachment_id3_keys().

Props nacin.
See #27574.

File:
1 edited

Legend:

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

    r27864 r27869  
    26622662        <div class="wp_attachment_details edit-form-section">
    26632663                <p>
    2664                         <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong><?php
    2665                         if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ): ?>: <?php
    2666                                 _e( "Custom label for item in a playlist. If empty, the file's available data is used." );
    2667                         endif ?></label><br />
     2664                        <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
    26682665                        <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
    26692666                </p>
    … …  
    26892686
    26902687        <label for="content"><strong><?php _e( 'Description' ); ?></strong><?php
    2691         if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ): ?>: <?php
    2692                 _e( 'Displayed on attachment pages.' );
    2693         endif ?></label>
     2688        if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
     2689                echo ': ' . __( 'Displayed on attachment pages.' );
     2690        } ?></label>
    26942691        <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
    26952692
    … …  
    27292726        <div class="misc-pub-section misc-pub-filetype">
    27302727                <?php _e( 'File type:' ); ?> <strong><?php
    2731                         if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
     2728                        if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) {
    27322729                                echo esc_html( strtoupper( $matches[1] ) );
    2733                         else
     2730                                list( $mime_type ) = explode( '/', $post->post_mime_type );
     2731                                if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) {
     2732                                        if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) {
     2733                                                echo ' (' . $meta['mime_type'] . ')';
     2734                                        }
     2735                                }
     2736                        } else {
    27342737                                echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
     2738                        }
    27352739                ?></strong>
    27362740        </div>
    … …  
    27522756                endif;
    27532757
    2754         if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ):
     2758        if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
    27552759
    27562760                /**
    … …  
    27622766                 * @since 3.7.0
    27632767                 *
    2764                  * @param array $fields {
    2765                  *     An array of the attachment metadata keys and labels.
    2766                  *
    2767                  *     @type string $mime_type        Label to be shown before the field mime_type.
    2768                  *     @type string $year             Label to be shown before the field year.
    2769                  *     @type string $genre            Label to be shown before the field genre.
    2770                  *     @type string $length_formatted Label to be shown before the field length_formatted.
    2771                  * }
     2768                 * @param array $fields An array of the attachment metadata keys and labels.
    27722769                 */
    27732770                $fields = apply_filters( 'media_submitbox_misc_sections', array(
    2774                         'mime_type'        => __( 'Mime-type:' ),
    27752771                        'length_formatted' => __( 'Length:' ),
     2772                        'bitrate'          => __( 'Bitrate:' ),
    27762773                ) );
    27772774
    2778                 foreach ( $fields as $key => $label ):
    2779                         if ( ! empty( $meta[$key] ) ) : ?>
     2775                foreach ( $fields as $key => $label ) {
     2776                        if ( empty( $meta[ $key ] ) ) {
     2777                                continue;
     2778                        }
     2779        ?>
    27802780                <div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>">
    2781                         <?php echo $label ?> <strong><?php echo esc_html( $meta[$key] ); ?></strong>
    2782                 </div>
    2783         <?php
    2784                         endif;
    2785                 endforeach;
    2786 
    2787                 if ( ! empty( $meta['bitrate'] ) ) : ?>
    2788                 <div class="misc-pub-section misc-pub-bitrate">
    2789                         <?php _e( 'Bitrate:' ); ?> <strong><?php
    2790                                 echo round( $meta['bitrate'] / 1000 ), 'kb/s';
    2791 
    2792                                 if ( ! empty( $meta['bitrate_mode'] ) )
    2793                                         echo ' ', strtoupper( $meta['bitrate_mode'] );
    2794 
     2781                        <?php echo $label ?> <strong><?php
     2782                                switch ( $key ) {
     2783                                        case 'bitrate' :
     2784                                                echo round( $meta['bitrate'] / 1000 ) . 'kb/s';
     2785                                                if ( ! empty( $meta['bitrate_mode'] ) ) {
     2786                                                        echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) );
     2787                                                }
     2788                                                break;
     2789                                        default:
     2790                                                echo esc_html( $meta[ $key ] );
     2791                                                break;
     2792                                }
    27952793                        ?></strong>
    27962794                </div>
    27972795        <?php
    2798                 endif;
     2796                }
    27992797
    28002798                /**
    … …  
    28062804                 * @since 3.7.0
    28072805                 *
    2808                  * @param array $fields {
    2809                  *     An array of the attachment metadata keys and labels.
    2810                  *
    2811                  *     @type string $dataformat Label to be shown before the field dataformat.
    2812                  *     @type string $codec      Label to be shown before the field codec.
    2813                  * }
     2806                 * @param array $fields An array of the attachment metadata keys and labels.
    28142807                 */
    28152808                $audio_fields = apply_filters( 'audio_submitbox_misc_sections', array(
    … …  
    28182811                ) );
    28192812
    2820                 foreach ( $audio_fields as $key => $label ):
    2821                         if ( ! empty( $meta['audio'][$key] ) ) : ?>
     2813                foreach ( $audio_fields as $key => $label ) {
     2814                        if ( empty( $meta['audio'][ $key ] ) ) {
     2815                                continue;
     2816                        }
     2817        ?>
    28222818                <div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>">
    28232819                        <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][$key] ); ?></strong>
    28242820                </div>
    28252821        <?php
    2826                         endif;
    2827                 endforeach;
    2828 
    2829         endif;
     2822                }
     2823
     2824        }
    28302825
    28312826        if ( $media_dims ) : ?>
Note: See TracChangeset for help on using the changeset viewer.