mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 06:37:06 +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:
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -2661,10 +2661,14 @@ function edit_form_image_editor( $post ) {
|
||||
</div>
|
||||
<div class="wp_attachment_details edit-form-section">
|
||||
<p>
|
||||
<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
|
||||
<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong><?php
|
||||
if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): ?>: <?php
|
||||
_e( "Custom label for item in a playlist. If empty, the file's available data is used." );
|
||||
endif ?></label><br />
|
||||
<textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
|
||||
</p>
|
||||
|
||||
|
||||
<?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?>
|
||||
<p>
|
||||
<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
|
||||
@@ -2683,7 +2687,10 @@ function edit_form_image_editor( $post ) {
|
||||
);
|
||||
?>
|
||||
|
||||
<label for="content"><strong><?php _e( 'Description' ); ?></strong></label>
|
||||
<label for="content"><strong><?php _e( 'Description' ); ?></strong><?php
|
||||
if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): ?>: <?php
|
||||
_e( 'Displayed on attachment pages.' );
|
||||
endif ?></label>
|
||||
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
|
||||
|
||||
</div>
|
||||
@@ -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:' ),
|
||||
) );
|
||||
|
||||
|
||||
@@ -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 ): ?>
|
||||
<p>
|
||||
<label for="title"><?php echo $label ?></label>
|
||||
<input type="text" name="id3_<?php echo esc_attr( $key ) ?>" id="id3_<?php echo esc_attr( $key ) ?>" class="widefat" value="<?php
|
||||
if ( ! empty( $meta[ $key ] ) ) {
|
||||
echo esc_attr( $meta[ $key ] );
|
||||
}
|
||||
?>" />
|
||||
</p>
|
||||
<?php endforeach;
|
||||
}
|
||||
@@ -237,6 +237,24 @@ function edit_post( $post_data = null ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'attachment' === $post_data['post_type'] && preg_match( '#^audio|video#', $post_data['post_mime_type'] ) ) {
|
||||
$id3data = wp_get_attachment_metadata( $post_ID );
|
||||
if ( ! is_array( $id3data ) ) {
|
||||
$id3data = array();
|
||||
}
|
||||
|
||||
foreach ( wp_get_relevant_id3_keys() as $key => $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 ) {
|
||||
|
||||
Reference in New Issue
Block a user