WordPress.org

Make WordPress Core

Changeset 22673


Ignore:
Timestamp:
11/19/12 08:10:38 (3 years ago)
Author:
nacin
Message:

Move code from image_attachment_fields_to_edit() to get_attachment_fields_to_edit(). The level of abstraction is unnecessary, and it makes it more difficult to call only the filter in the new media modal. Also, that function is sloooow. see #22186.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r22670 r22673  
    811811 */ 
    812812function image_attachment_fields_to_edit($form_fields, $post) { 
    813     if ( substr($post->post_mime_type, 0, 5) == 'image' ) { 
    814         $alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true); 
    815         if ( empty($alt) ) 
    816             $alt = ''; 
    817  
    818         $form_fields['post_title']['required'] = true; 
    819  
    820         $form_fields['image_alt'] = array( 
    821             'value' => $alt, 
    822             'label' => __('Alternative Text'), 
    823             'helps' => __('Alt text for the image, e.g. “The Mona Lisa”') 
    824         ); 
    825  
    826         $form_fields['align'] = array( 
    827             'label' => __('Alignment'), 
    828             'input' => 'html', 
    829             'html'  => image_align_input_fields($post, get_option('image_default_align')), 
    830         ); 
    831  
    832         $form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') ); 
    833  
    834     } else { 
    835         unset( $form_fields['image_alt'] ); 
    836     } 
    837813    return $form_fields; 
    838814} 
    839  
    840 add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2); 
    841815 
    842816/** 
     
    1001975    $form_fields = array_merge_recursive($form_fields, (array) $errors); 
    1002976 
     977    // This was formerly in image_attachment_fields_to_edit(). 
     978    if ( substr($post->post_mime_type, 0, 5) == 'image' ) { 
     979        $alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true); 
     980        if ( empty($alt) ) 
     981            $alt = ''; 
     982 
     983        $form_fields['post_title']['required'] = true; 
     984 
     985        $form_fields['image_alt'] = array( 
     986            'value' => $alt, 
     987            'label' => __('Alternative Text'), 
     988            'helps' => __('Alt text for the image, e.g. “The Mona Lisa”') 
     989        ); 
     990 
     991        $form_fields['align'] = array( 
     992            'label' => __('Alignment'), 
     993            'input' => 'html', 
     994            'html'  => image_align_input_fields($post, get_option('image_default_align')), 
     995        ); 
     996 
     997        $form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') ); 
     998 
     999    } else { 
     1000        unset( $form_fields['image_alt'] ); 
     1001    } 
     1002 
     1003    return $form_fields; 
     1004 
    10031005    $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); 
    10041006 
Note: See TracChangeset for help on using the changeset viewer.