diff --git wp-admin/css/wp-admin.dev.css wp-admin/css/wp-admin.dev.css index 3b9dca7..c675425 100644 --- wp-admin/css/wp-admin.dev.css +++ wp-admin/css/wp-admin.dev.css @@ -3724,7 +3724,8 @@ abbr.required { } .media-item .describe input[type="text"], -.media-item .describe textarea { +.media-item .describe textarea, +.media-item .wp-editor-wrap { width: 460px; } @@ -3906,10 +3907,6 @@ abbr.required { border-radius: 3px; } -.media-item .post_excerpt textarea { - height: 60px; -} - /*------------------------------------------------------------------------------ 14.1 - Media Library ------------------------------------------------------------------------------*/ diff --git wp-admin/includes/media.php wp-admin/includes/media.php index 0ae2f10..bff6338 100644 --- wp-admin/includes/media.php +++ wp-admin/includes/media.php @@ -788,25 +788,46 @@ function image_link_input_fields($post, $url_type = '') { "; } -function wp_caption_input_textarea($edit_post) { +/** + * Render an editor for image caption + * + * @see `get_attachment_fields_to_edit()` + * @since 3.4 + * + * @param Object $edit_post, media item object, default is false + * @param String $name, the name/id of the textarea if $edit_post is false, default is `caption` + * @param String $caption, value for caption if $edit_post is false, default is `` + * @return String, the generated html + */ +function wp_caption_input_textarea( $edit_post = false, $name = 'caption', $caption = '' ) { // post data is already escaped - $name = "attachments[{$edit_post->ID}][post_excerpt]"; + if ( $edit_post ) { + $name = "attachments[{$edit_post->ID}][post_excerpt]"; + $caption = $edit_post->post_excerpt; + } - return ' - -
- '; + $defaults = array( + 'teeny' => true, + 'tinymce' => false, + 'media_buttons' => false, + 'textarea_rows' => 10, + 'quicktags' => array( + 'buttons' => 'strong,em,link,del,ins,code,close' + ) + ); + $settings = apply_filters( 'caption_input_textarea', $defaults, $edit_post ); + // Do not load wpLink if tinymce is not present + // Just plain Quicktags link handler + if ( !$settings['tinymce'] ) + wp_deregister_script( 'wplink' ); + + if ( defined( 'IFRAME_REQUEST' ) && IFRAME_REQUEST == true ) + wp_enqueue_script( 'quicktags' ); + + // Use a buffer to get the output, otherway it will just echo everything + ob_start(); + wp_editor( $caption, $name, $settings ); + return ob_get_clean(); } /** @@ -953,7 +974,7 @@ function get_attachment_fields_to_edit($post, $errors = null) { 'post_excerpt' => array( 'label' => __('Default Caption'), 'input' => 'html', - 'html' => wp_caption_input_textarea($edit_post) + 'html' => wp_caption_input_textarea( $edit_post ) ), 'post_content' => array( 'label' => __('Description'), @@ -1951,9 +1972,8 @@ function wp_media_insert_url_form( $default_view = 'image' ) {