Attachment editor improvements. Put the non-editable metadata into the submit/publish box.
Props helenyhou see #21391 git-svn-id: http://core.svn.wordpress.org/trunk@22364 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
825bea7637
commit
ad724f3b7b
|
@ -5826,7 +5826,7 @@ table.form-table td .updated {
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
#poststuff .postarea {
|
||||
#post-body-content {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ if ( 'attachment' == $post_type ) {
|
|||
wp_enqueue_script( 'image-edit' );
|
||||
wp_enqueue_style( 'imgareaselect' );
|
||||
add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
|
||||
add_meta_box( 'attachmentdata', __('Attachment Page Content'), 'attachment_data_meta_box', null, 'normal', 'core' );
|
||||
add_meta_box( 'attachmentdata', __('Attachment Page Content'), 'attachment_content_meta_box', null, 'normal', 'core' );
|
||||
add_action( 'edit_form_after_title', 'edit_form_image_editor' );
|
||||
} else {
|
||||
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );
|
||||
|
|
|
@ -2122,6 +2122,7 @@ function edit_form_image_editor() {
|
|||
|
||||
$filename = esc_html( basename( $post->guid ) );
|
||||
$title = esc_attr( $post->post_title );
|
||||
$alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
|
||||
|
||||
$post_mime_types = get_post_mime_types();
|
||||
$keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
|
||||
|
@ -2151,22 +2152,57 @@ function edit_form_image_editor() {
|
|||
<p><?php echo $image_edit_button; ?></p>
|
||||
</div>
|
||||
<div style="display:none" class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"></div>
|
||||
</div>
|
||||
|
||||
<div class="wp_attachment_details">
|
||||
<p>
|
||||
<label for="attachment_url"><strong><?php _e( 'File URL' ); ?></strong></label><br />
|
||||
<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" /><br />
|
||||
</p>
|
||||
<p><strong><?php _e( 'File name:' ); ?></strong> <?php echo $filename; ?><br />
|
||||
<strong><?php _e( 'File type:' ); ?></strong> <?php echo $post->post_mime_type; ?>
|
||||
<?php
|
||||
if ( $media_dims )
|
||||
echo '<br /><strong>' . __( 'Dimensions:' ) . '</strong> ' . $media_dims;
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="wp_attachment_details">
|
||||
<p>
|
||||
<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
|
||||
<textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
|
||||
</p>
|
||||
<p>
|
||||
<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
|
||||
<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" />
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
// need a filter on this content
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays non-editable attachment metadata in the publish metabox
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
function attachment_submitbox_metadata() {
|
||||
$post = get_post();
|
||||
|
||||
$filename = esc_html( basename( $post->guid ) );
|
||||
|
||||
$media_dims = '';
|
||||
$meta = wp_get_attachment_metadata( $post->ID );
|
||||
if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
|
||||
$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> ";
|
||||
$media_dims = apply_filters( 'media_meta', $media_dims, $post );
|
||||
|
||||
$att_url = wp_get_attachment_url( $post->ID );
|
||||
?>
|
||||
<div class="misc-pub-section">
|
||||
<label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
|
||||
<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" />
|
||||
</div>
|
||||
<div class="misc-pub-section">
|
||||
<?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong>
|
||||
</div>
|
||||
<div class="misc-pub-section">
|
||||
<?php _e( 'File type:' ); ?> <strong><?php echo $post->post_mime_type; ?></strong>
|
||||
</div>
|
||||
|
||||
<?php if ( $media_dims ) : ?>
|
||||
<div class="misc-pub-section">
|
||||
<?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
|
||||
add_filter( 'async_upload_image', 'get_media_item', 10, 2 );
|
||||
|
@ -2181,3 +2217,5 @@ add_action( 'media_upload_file', 'wp_media_upload_handler' );
|
|||
|
||||
add_filter( 'media_upload_gallery', 'media_upload_gallery' );
|
||||
add_filter( 'media_upload_library', 'media_upload_library' );
|
||||
|
||||
add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' );
|
||||
|
|
|
@ -302,8 +302,7 @@ function attachment_submit_meta_box( $post ) {
|
|||
*
|
||||
* @param object $post
|
||||
*/
|
||||
function attachment_data_meta_box( $post ) {
|
||||
$alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
|
||||
function attachment_content_meta_box( $post ) {
|
||||
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' );
|
||||
$editor_args = array(
|
||||
'textarea_name' => 'content',
|
||||
|
@ -317,15 +316,6 @@ function attachment_data_meta_box( $post ) {
|
|||
<label class="screen-reader-text" for="content"><strong><?php _e( 'Attachment Page Content' ); ?></strong></label>
|
||||
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
|
||||
<textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
|
||||
</p>
|
||||
<p>
|
||||
<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
|
||||
<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" />
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue