WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/30/2014 07:27:31 PM (7 years ago)
Author:
wonderboymusic
Message:

Metadata for audio and video files:

  • Make attachment metadata for audio files editable by providing a metabox on the Edit Media page
  • Standardize on using the attachment title everywhere
  • Label the Caption and Description fields for audio and video appropriately
  • Make the playlist Underscore templates more straightforward

See #27574.

File:
1 edited

Legend:

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

    r27813 r27862  
    10191019    <img src="{{{ data.thumb.src }}}"/>
    10201020    <# } #>
    1021     <# if ( data.meta.title ) { #>
    10221021    <div class="wp-playlist-caption">
    1023         <span class="wp-caption-meta wp-caption-title">&#8220;{{{ data.meta.title }}}&#8221;</span>
    1024         <span class="wp-caption-meta wp-caption-album">{{{ data.meta.album }}}</span>
    1025         <span class="wp-caption-meta wp-caption-artist">{{{ data.meta.artist }}}</span>
     1022        <span class="wp-caption-meta wp-caption-title">&#8220;{{{ data.title }}}&#8221;</span>
     1023        <# if ( data.meta.album ) { #><span class="wp-caption-meta wp-caption-album">{{{ data.meta.album }}}</span><# } #>
     1024        <# if ( data.meta.artist ) { #><span class="wp-caption-meta wp-caption-artist">{{{ data.meta.artist }}}</span><# } #>
    10261025    </div>
    1027     <# } else { #>
    1028     <div class="wp-playlist-caption">{{{ data.caption ? data.caption : data.title }}}</div>
    1029     <# } #>
    10301026</script>
    10311027<script type="text/html" id="tmpl-wp-playlist-item">
    10321028    <div class="wp-playlist-item">
    1033         <# if ( ( data.title || data.meta.title ) && ( ! data.artists || data.meta.artist ) ) { #>
    10341029        <div class="wp-playlist-caption">
    10351030            {{{ data.index ? ( data.index + '.&nbsp;' ) : '' }}}
    1036             <span class="wp-caption-title">&#8220;{{{ data.title ? data.title : data.meta.title }}}&#8221;</span>
    1037             <# if ( data.artists ) { #>
    1038             <span class="wp-caption-by"><?php _e( 'by' ) ?></span>
    1039             <span class="wp-caption-artist">{{{ data.meta.artist }}}</span>
     1031            <# if ( data.caption ) { #>
     1032                {{{ data.caption }}}
     1033            <# } else { #>
     1034                <span class="wp-caption-title">&#8220;{{{ data.title }}}&#8221;</span>
     1035                <# if ( data.artists && data.meta.artist ) { #>
     1036                <span class="wp-caption-by"><?php _e( 'by' ) ?></span>
     1037                <span class="wp-caption-artist">{{{ data.meta.artist }}}</span>
     1038                <# } #>
    10401039            <# } #>
    10411040        </div>
    1042         <# } else { #>
    1043         <div class="wp-playlist-caption">{{{ data.index ? ( data.index + '.' ) : '' }}} {{{ data.caption ? data.caption : data.title }}}</div>
    1044         <# } #>
    10451041        <# if ( data.meta.length_formatted ) { #>
    10461042        <div class="wp-playlist-item-length">{{{ data.meta.length_formatted }}}</div>
     
    12081204        if ( ! empty( $meta ) ) {
    12091205
    1210             $keys = array( 'title', 'artist', 'band', 'album', 'genre', 'year', 'length', 'length_formatted' );
    1211             foreach ( $keys as $key ) {
     1206            foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
    12121207                if ( ! empty( $meta[ $key ] ) ) {
    12131208                    $track['meta'][ $key ] = $meta[ $key ];
     
    13181313}
    13191314
     1315/**
     1316 * Return useful keys to use to lookup data from an attachment's stored metadata
     1317 *
     1318 * @since 3.9.0
     1319 *
     1320 * @return array
     1321 */
     1322function wp_get_relevant_id3_keys() {
     1323    $fields = array(
     1324        'artist' => __( 'Artist' ),
     1325        'album' => __( 'Album' ),
     1326        'genre' => __( 'Genre' ),
     1327        'year' => __( 'Year' ),
     1328        'length_formatted' => __( 'Formatted Length' )
     1329    );
     1330    /**
     1331     * Filter the editable list of keys to lookup data from an attachment's metadata
     1332     *
     1333     * @since 3.9.0
     1334     *
     1335     * @param array $fields
     1336     */
     1337    return apply_filters( 'wp_get_relevant_id3_keys', $fields );
     1338}
    13201339/**
    13211340 * The Audio shortcode.
     
    23132332
    23142333        $response['meta'] = array();
    2315         $keys = array( 'title', 'artist', 'band', 'album', 'genre', 'year', 'length', 'length_formatted' );
    2316         foreach ( $keys as $key ) {
     2334        foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
    23172335            if ( ! empty( $meta[ $key ] ) ) {
    23182336                $response['meta'][ $key ] = $meta[ $key ];
Note: See TracChangeset for help on using the changeset viewer.