Make WordPress Core

Ticket #21391: 21391.4.diff

File 21391.4.diff, 6.1 KB (added by helenyhou, 13 years ago)
  • wp-admin/includes/meta-boxes.php

     
    302302 *
    303303 * @param object $post
    304304 */
    305 function attachment_data_meta_box( $post ) {
    306         $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
     305function attachment_content_meta_box( $post ) {
    307306        $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' );
    308307        $editor_args = array(
    309308                'textarea_name' => 'content',
     
    317316        <label class="screen-reader-text" for="content"><strong><?php _e( 'Attachment Page Content' ); ?></strong></label>
    318317        <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
    319318</p>
    320 
    321 <p>
    322         <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
    323         <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
    324 </p>
    325 <p>
    326         <label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
    327         <input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" />
    328 </p>
    329319<?php
    330320}
    331321
    332322/**
     323 * Displays non-editable attachment metadata
     324 *
     325 * @since 3.5.0
     326 */
     327function attachment_metadata_meta_box() {
     328        $post = get_post();
     329
     330        $attachment_id = intval( $post->ID );
     331        $filename = esc_html( basename( $post->guid ) );
     332        $title = esc_attr( $post->post_title );
     333
     334        $post_mime_types = get_post_mime_types();
     335        $keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
     336        $type = array_shift( $keys );
     337        $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
     338
     339        $media_dims = '';
     340        $meta = wp_get_attachment_metadata( $post->ID );
     341        if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
     342                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
     343        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
     344
     345        $att_url = wp_get_attachment_url( $post->ID );
     346
     347        $output = '
     348        <div class="wp_attachment_details">
     349                <p>
     350                        <label for="attachment_url"><strong>' . __( 'File URL' ) . '</strong></label><br />
     351                        <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="' . esc_attr($att_url) . '" /><br />
     352                </p>
     353                <p><strong>' . __( 'File name:' ) . '</strong> ' . $filename . '<br />
     354                <strong>' . __( 'File type:' ) . '</strong> ' . $post->post_mime_type;
     355
     356                if ( $media_dims )
     357                        $output .= '<br /><strong>' . __( 'Dimensions:' ) . '</strong> ' . $media_dims;
     358
     359                $output .= '
     360                </p>
     361        </div>';
     362
     363        $output = apply_filters( 'edit_form_attachment_metadata', $output, $post );
     364
     365        echo $output;
     366}
     367
     368/**
    333369 * Display post format form elements.
    334370 *
    335371 * @since 3.1.0
  • wp-admin/includes/media.php

     
    21222122
    21232123        $filename = esc_html( basename( $post->guid ) );
    21242124        $title = esc_attr( $post->post_title );
     2125        $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
    21252126
    21262127        $post_mime_types = get_post_mime_types();
    21272128        $keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
     
    21512152                        <p><?php echo $image_edit_button; ?></p>
    21522153                </div>
    21532154                <div style="display:none" class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"></div>
     2155        </div>
    21542156
    2155                 <div class="wp_attachment_details">
    2156                         <p>
    2157                                 <label for="attachment_url"><strong><?php _e( 'File URL' ); ?></strong></label><br />
    2158                                 <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" /><br />
    2159                         </p>
    2160                         <p><strong><?php _e( 'File name:' ); ?></strong> <?php echo $filename; ?><br />
    2161                         <strong><?php _e( 'File type:' ); ?></strong> <?php echo $post->post_mime_type; ?>
    2162                         <?php
    2163                                 if ( $media_dims )
    2164                                         echo '<br /><strong>' . __( 'Dimensions:' ) . '</strong> ' . $media_dims;
    2165                         ?>
    2166                         </p>
    2167                 </div>
     2157        <div class="wp_attachment_details">
     2158                <p>
     2159                        <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
     2160                        <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
     2161                </p>
     2162                <p>
     2163                        <label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
     2164                        <input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" />
     2165                </p>
    21682166        </div>
    21692167        <?php
     2168        // need a filter on this content
    21702169}
    21712170
    21722171add_filter( 'async_upload_image', 'get_media_item', 10, 2 );
  • wp-admin/edit-form-advanced.php

     
    111111        wp_enqueue_script( 'image-edit' );
    112112        wp_enqueue_style( 'imgareaselect' );
    113113        add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
    114         add_meta_box( 'attachmentdata', __('Attachment Page Content'), 'attachment_data_meta_box', null, 'normal', 'core' );
     114        add_meta_box( 'attachmentmeta', __('Meta Data'), 'attachment_metadata_meta_box', null, 'side', 'core' );
     115        add_meta_box( 'attachmentdata', __('Attachment Page Content'), 'attachment_content_meta_box', null, 'normal', 'core' );
    115116        add_action( 'edit_form_after_title', 'edit_form_image_editor' );
    116117} else {
    117118        add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );
  • wp-admin/css/wp-admin.css

     
    58265826        padding: 0;
    58275827}
    58285828
    5829 #poststuff .postarea {
     5829#post-body-content {
    58305830        margin-bottom: 20px;
    58315831}
    58325832