From d947a554957f16e0e3d51abf344bc495e7c6750d Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 30 Mar 2014 19:28:16 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@27862 git-svn-id: http://core.svn.wordpress.org/trunk@27693 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 4 +++ wp-admin/includes/media.php | 13 +++++--- wp-admin/includes/meta-boxes.php | 25 ++++++++++++++ wp-admin/includes/post.php | 18 ++++++++++ wp-includes/media.php | 56 +++++++++++++++++++++----------- 5 files changed, 93 insertions(+), 23 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index f7b22812ae..7f0ea62f6a 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -139,6 +139,10 @@ if ( 'attachment' == $post_type ) { wp_enqueue_style( 'imgareaselect' ); add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' ); add_action( 'edit_form_after_title', 'edit_form_image_editor' ); + + if ( preg_match( '#^audio#', $post->post_mime_type ) ) { + add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' ); + } } else { add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); } diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index ccc4ab4b39..47bbfdb509 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -2661,10 +2661,14 @@ function edit_form_image_editor( $post ) {

-
+

+ post_mime_type, 0, 5 ) ) : ?>


@@ -2683,7 +2687,10 @@ function edit_form_image_editor( $post ) { ); ?> - + post_content, 'attachment_content', $editor_args ); ?>

@@ -2765,8 +2772,6 @@ function attachment_submitbox_metadata() { */ $fields = apply_filters( 'media_submitbox_misc_sections', array( 'mime_type' => __( 'Mime-type:' ), - 'year' => __( 'Year:' ), - 'genre' => __( 'Genre:' ), 'length_formatted' => __( 'Length:' ), ) ); diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index be89c366bf..f91df90347 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/wp-admin/includes/meta-boxes.php @@ -1057,3 +1057,28 @@ function post_thumbnail_meta_box( $post ) { $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID ); } + +/** + * Display fields for ID3 data + * + * @since 3.9.0 + * + * @param WP_Post $post + */ +function attachment_id3_data_meta_box( $post ) { + $meta = array(); + if ( ! empty( $post->ID ) ) { + $meta = wp_get_attachment_metadata( $post->ID ); + } + + foreach ( wp_get_relevant_id3_keys() as $key => $label ): ?> +

+ + +

+ $label ) { + if ( isset( $post_data[ 'id3_' . $key ] ) ) { + if ( current_user_can( 'unfiltered_html' ) ) { + $id3data[ $key ] = wp_unslash( $post_data[ 'id3_' . $key ] ); + } else { + $id3data[ $key ] = wp_unslash( wp_kses_post( $post_data[ 'id3_' . $key ] ) ); + } + } + } + wp_update_attachment_metadata( $post_ID, $id3data ); + } + // Meta Stuff if ( isset($post_data['meta']) && $post_data['meta'] ) { foreach ( $post_data['meta'] as $key => $value ) { diff --git a/wp-includes/media.php b/wp-includes/media.php index d9f00267cc..6c1ddaeb01 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1018,30 +1018,26 @@ function wp_underscore_playlist_templates() { <# if ( data.image ) { #> <# } #> - <# if ( data.meta.title ) { #>
- “{{{ data.meta.title }}}” - {{{ data.meta.album }}} - {{{ data.meta.artist }}} + “{{{ data.title }}}” + <# if ( data.meta.album ) { #>{{{ data.meta.album }}}<# } #> + <# if ( data.meta.artist ) { #>{{{ data.meta.artist }}}<# } #>
- <# } else { #> -
{{{ data.caption ? data.caption : data.title }}}
- <# } #>