WordPress.org

Make WordPress Core

Changeset 22364


Ignore:
Timestamp:
11/05/2012 02:04:22 PM (8 years ago)
Author:
ryan
Message:

Attachment editor improvements. Put the non-editable metadata into the submit/publish box.

Props helenyhou
see #21391

Location:
trunk/wp-admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/wp-admin.css

    r22329 r22364  
    58275827}
    58285828
    5829 #poststuff .postarea {
     5829#post-body-content {
    58305830    margin-bottom: 20px;
    58315831}
  • trunk/wp-admin/edit-form-advanced.php

    r22291 r22364  
    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( 'attachmentdata', __('Attachment Page Content'), 'attachment_content_meta_box', null, 'normal', 'core' );
    115115    add_action( 'edit_form_after_title', 'edit_form_image_editor' );
    116116} else {
  • trunk/wp-admin/includes/media.php

    r22105 r22364  
    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();
     
    21522153        </div>
    21532154        <div style="display:none" class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"></div>
    2154 
    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>
     2155    </div>
     2156
     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
     2169}
     2170
     2171/**
     2172 * Displays non-editable attachment metadata in the publish metabox
     2173 *
     2174 * @since 3.5.0
     2175 */
     2176function attachment_submitbox_metadata() {
     2177    $post = get_post();
     2178
     2179    $filename = esc_html( basename( $post->guid ) );
     2180
     2181    $media_dims = '';
     2182    $meta = wp_get_attachment_metadata( $post->ID );
     2183    if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
     2184        $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
     2185    $media_dims = apply_filters( 'media_meta', $media_dims, $post );
     2186
     2187    $att_url = wp_get_attachment_url( $post->ID );
     2188?>
     2189    <div class="misc-pub-section">
     2190            <label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
     2191            <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" />
     2192    </div>
     2193    <div class="misc-pub-section">
     2194        <?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong>
     2195    </div>
     2196    <div class="misc-pub-section">
     2197        <?php _e( 'File type:' ); ?> <strong><?php echo $post->post_mime_type; ?></strong>
     2198    </div>
     2199
     2200<?php if ( $media_dims ) : ?>
     2201    <div class="misc-pub-section">
     2202        <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
     2203    </div>
     2204<?php
     2205    endif;
    21702206}
    21712207
     
    21822218add_filter( 'media_upload_gallery', 'media_upload_gallery' );
    21832219add_filter( 'media_upload_library', 'media_upload_library' );
     2220
     2221add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' );
  • trunk/wp-admin/includes/meta-boxes.php

    r22321 r22364  
    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(
     
    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 ); ?>
    319 </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 ); ?>" />
    328318</p>
    329319<?php
Note: See TracChangeset for help on using the changeset viewer.