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.
git-svn-id: https://develop.svn.wordpress.org/trunk@22673 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ae2f322e25
commit
f4b9859903
|
@ -810,35 +810,9 @@ function wp_caption_input_textarea($edit_post) {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function image_attachment_fields_to_edit($form_fields, $post) {
|
function image_attachment_fields_to_edit($form_fields, $post) {
|
||||||
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
|
|
||||||
$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
|
|
||||||
if ( empty($alt) )
|
|
||||||
$alt = '';
|
|
||||||
|
|
||||||
$form_fields['post_title']['required'] = true;
|
|
||||||
|
|
||||||
$form_fields['image_alt'] = array(
|
|
||||||
'value' => $alt,
|
|
||||||
'label' => __('Alternative Text'),
|
|
||||||
'helps' => __('Alt text for the image, e.g. “The Mona Lisa”')
|
|
||||||
);
|
|
||||||
|
|
||||||
$form_fields['align'] = array(
|
|
||||||
'label' => __('Alignment'),
|
|
||||||
'input' => 'html',
|
|
||||||
'html' => image_align_input_fields($post, get_option('image_default_align')),
|
|
||||||
);
|
|
||||||
|
|
||||||
$form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
unset( $form_fields['image_alt'] );
|
|
||||||
}
|
|
||||||
return $form_fields;
|
return $form_fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@internal Missing Short Description}}
|
* {@internal Missing Short Description}}
|
||||||
*
|
*
|
||||||
|
@ -1000,6 +974,34 @@ function get_attachment_fields_to_edit($post, $errors = null) {
|
||||||
// The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing )
|
// The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing )
|
||||||
$form_fields = array_merge_recursive($form_fields, (array) $errors);
|
$form_fields = array_merge_recursive($form_fields, (array) $errors);
|
||||||
|
|
||||||
|
// This was formerly in image_attachment_fields_to_edit().
|
||||||
|
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
|
||||||
|
$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
|
||||||
|
if ( empty($alt) )
|
||||||
|
$alt = '';
|
||||||
|
|
||||||
|
$form_fields['post_title']['required'] = true;
|
||||||
|
|
||||||
|
$form_fields['image_alt'] = array(
|
||||||
|
'value' => $alt,
|
||||||
|
'label' => __('Alternative Text'),
|
||||||
|
'helps' => __('Alt text for the image, e.g. “The Mona Lisa”')
|
||||||
|
);
|
||||||
|
|
||||||
|
$form_fields['align'] = array(
|
||||||
|
'label' => __('Alignment'),
|
||||||
|
'input' => 'html',
|
||||||
|
'html' => image_align_input_fields($post, get_option('image_default_align')),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
unset( $form_fields['image_alt'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $form_fields;
|
||||||
|
|
||||||
$form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post);
|
$form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post);
|
||||||
|
|
||||||
return $form_fields;
|
return $form_fields;
|
||||||
|
|
Loading…
Reference in New Issue