Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I change the 'Caption' text input to text area, to allow for multi line captions on media uploads?

share|improve this question

1 Answer 1

I don't think you can do that, however you can implement this code in your functions file to at least allow for line breaks in single image captions

Note: doesn't work for gallery images (I am trying to find a way to make it work in galleries)

/*
*********************************************
Function to allow multi-line photo captions.
This function will split captions onto multiple lines if it detects
a "|" (pipe) symbol.
**********************************************
*/
/* Override existing caption shortcode handlers with our own */
add_shortcode('wp_caption', 'multiline_caption');
add_shortcode('caption', 'multiline_caption');

/* Our new function */
function multiline_caption($attr, $content = null) {
extract(shortcode_atts(array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
), $attr));

if ( 1 > (int) $width || empty($caption) )
return $content;

if ( $id ) $id = 'id="' . esc_attr($id) . '" ';

$new_caption = str_replace("|", "<br />", $caption);

return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . (10 + (int) $width) . 'px">'
. do_shortcode( $content ) . '<p class="wp-caption-text">' . $new_caption . '</p></div>'; }

Original code by Mark Wood: http://digitalnotions.net/multi-line-captions-in-wordpress

share|improve this answer
    
Did that work for you? If that's helpful, please accept! Thanks –  Sol Mar 14 '12 at 20:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.