mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@27862 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+37
-19
@@ -1018,30 +1018,26 @@ function wp_underscore_playlist_templates() {
|
||||
<# if ( data.image ) { #>
|
||||
<img src="{{{ data.thumb.src }}}"/>
|
||||
<# } #>
|
||||
<# if ( data.meta.title ) { #>
|
||||
<div class="wp-playlist-caption">
|
||||
<span class="wp-caption-meta wp-caption-title">“{{{ data.meta.title }}}”</span>
|
||||
<span class="wp-caption-meta wp-caption-album">{{{ data.meta.album }}}</span>
|
||||
<span class="wp-caption-meta wp-caption-artist">{{{ data.meta.artist }}}</span>
|
||||
<span class="wp-caption-meta wp-caption-title">“{{{ data.title }}}”</span>
|
||||
<# if ( data.meta.album ) { #><span class="wp-caption-meta wp-caption-album">{{{ data.meta.album }}}</span><# } #>
|
||||
<# if ( data.meta.artist ) { #><span class="wp-caption-meta wp-caption-artist">{{{ data.meta.artist }}}</span><# } #>
|
||||
</div>
|
||||
<# } else { #>
|
||||
<div class="wp-playlist-caption">{{{ data.caption ? data.caption : data.title }}}</div>
|
||||
<# } #>
|
||||
</script>
|
||||
<script type="text/html" id="tmpl-wp-playlist-item">
|
||||
<div class="wp-playlist-item">
|
||||
<# if ( ( data.title || data.meta.title ) && ( ! data.artists || data.meta.artist ) ) { #>
|
||||
<div class="wp-playlist-caption">
|
||||
{{{ data.index ? ( data.index + '. ' ) : '' }}}
|
||||
<span class="wp-caption-title">“{{{ data.title ? data.title : data.meta.title }}}”</span>
|
||||
<# if ( data.artists ) { #>
|
||||
<span class="wp-caption-by"><?php _e( 'by' ) ?></span>
|
||||
<span class="wp-caption-artist">{{{ data.meta.artist }}}</span>
|
||||
<# if ( data.caption ) { #>
|
||||
{{{ data.caption }}}
|
||||
<# } else { #>
|
||||
<span class="wp-caption-title">“{{{ data.title }}}”</span>
|
||||
<# if ( data.artists && data.meta.artist ) { #>
|
||||
<span class="wp-caption-by"><?php _e( 'by' ) ?></span>
|
||||
<span class="wp-caption-artist">{{{ data.meta.artist }}}</span>
|
||||
<# } #>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } else { #>
|
||||
<div class="wp-playlist-caption">{{{ data.index ? ( data.index + '.' ) : '' }}} {{{ data.caption ? data.caption : data.title }}}</div>
|
||||
<# } #>
|
||||
<# if ( data.meta.length_formatted ) { #>
|
||||
<div class="wp-playlist-item-length">{{{ data.meta.length_formatted }}}</div>
|
||||
<# } #>
|
||||
@@ -1207,8 +1203,7 @@ function wp_playlist_shortcode( $attr ) {
|
||||
$meta = wp_get_attachment_metadata( $attachment->ID );
|
||||
if ( ! empty( $meta ) ) {
|
||||
|
||||
$keys = array( 'title', 'artist', 'band', 'album', 'genre', 'year', 'length', 'length_formatted' );
|
||||
foreach ( $keys as $key ) {
|
||||
foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
|
||||
if ( ! empty( $meta[ $key ] ) ) {
|
||||
$track['meta'][ $key ] = $meta[ $key ];
|
||||
}
|
||||
@@ -1317,6 +1312,30 @@ function wp_get_audio_extensions() {
|
||||
return apply_filters( 'wp_audio_extensions', array( 'mp3', 'ogg', 'wma', 'm4a', 'wav' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return useful keys to use to lookup data from an attachment's stored metadata
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wp_get_relevant_id3_keys() {
|
||||
$fields = array(
|
||||
'artist' => __( 'Artist' ),
|
||||
'album' => __( 'Album' ),
|
||||
'genre' => __( 'Genre' ),
|
||||
'year' => __( 'Year' ),
|
||||
'length_formatted' => __( 'Formatted Length' )
|
||||
);
|
||||
/**
|
||||
* Filter the editable list of keys to lookup data from an attachment's metadata
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param array $fields
|
||||
*/
|
||||
return apply_filters( 'wp_get_relevant_id3_keys', $fields );
|
||||
}
|
||||
/**
|
||||
* The Audio shortcode.
|
||||
*
|
||||
@@ -2312,8 +2331,7 @@ function wp_prepare_attachment_for_js( $attachment ) {
|
||||
$response['fileLength'] = $meta['length_formatted'];
|
||||
|
||||
$response['meta'] = array();
|
||||
$keys = array( 'title', 'artist', 'band', 'album', 'genre', 'year', 'length', 'length_formatted' );
|
||||
foreach ( $keys as $key ) {
|
||||
foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
|
||||
if ( ! empty( $meta[ $key ] ) ) {
|
||||
$response['meta'][ $key ] = $meta[ $key ];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user