diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 082888df07..6be0c86550 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1899,6 +1899,10 @@ function wp_ajax_save_attachment_compat() { if ( 'attachment' != $post['post_type'] ) wp_send_json_error(); + // Handle the description field automatically, if a plugin adds it back. + if ( isset( $attachment_data['post_content'] ) ) + $post['post_content'] = $attachment_data['post_content']; + $post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data ); if ( isset( $post['errors'] ) ) { diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 2f7f318931..fac17f0f1c 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -1287,6 +1287,7 @@ function get_compat_media_markup( $attachment_id, $args = null ) { $default_args = array( 'errors' => null, 'taxonomies' => false, + 'description' => false, ); $args = wp_parse_args( $args, $default_args ); @@ -1325,9 +1326,12 @@ function get_compat_media_markup( $attachment_id, $args = null ) { $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'], - $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'], + $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); + if ( ! $args['description'] ) + unset( $form_fields['post_content'] ); + $media_meta = apply_filters( 'media_meta', '', $post ); $defaults = array( diff --git a/wp-includes/media.php b/wp-includes/media.php index d203fd2429..57b4d845fd 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1388,7 +1388,7 @@ function wp_prepare_attachment_for_js( $attachment ) { } if ( function_exists('get_compat_media_markup') ) - $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'taxonomies' => true ) ); + $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'taxonomies' => true, 'description' => true ) ); return apply_filters( 'wp_prepare_attachment_for_js', $response, $attachment, $meta ); }