[wp-trac] [WordPress Trac] #18311: Support HTML in image captions. (was: Caption shortcode doesn't support markup in the caption.)

WordPress Trac wp-trac at lists.automattic.com
Mon Jan 16 20:57:52 UTC 2012


#18311: Support HTML in image captions.
----------------------------+-----------------------
 Reporter:  prettyboymp     |       Owner:  sushkov
     Type:  task (blessed)  |      Status:  assigned
 Priority:  normal          |   Milestone:  3.4
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  needs-patch     |
----------------------------+-----------------------
Changes (by azaozz):

 * status:  new => assigned
 * component:  TinyMCE => General
 * owner:   => sushkov
 * milestone:  Future Release => 3.4
 * keywords:  needs-patch has-patch => needs-patch
 * type:  enhancement => task (blessed)


Old description:

> The ability to add any HTML formatting to text in captions is very
> limited.
>
> - Markup can be added from the HTML editor as long as you don't switch to
> the visual editor and the markup does not contain any quotes.
>
> - The visual editor seems to completely ignore any markup when outputting
> to the actual input field.  Adding styling like <b> or <i> to text within
> the visual editor shows, but it doesn't save, nor does it still exist
> when switching to the HTML view.

New description:

 The ability to add any HTML formatting to text in captions is very
 limited.

 - HTML markup can be added from the HTML editor as long as you don't
 switch to the visual editor and the markup does not contain any quotes.
 - Currently the visual editor removes any HTML tags from captions.

 To do:
 - Handle HTML in the caption text escaping/encoding it to pass through the
 shortcode matching regex.
 - Provide some way of adding HTML in the captions in the gallery -> image
 properties. (This may be limited to links only as they seem most needed).
 - Improve editing of caption text in the visual editor after inserting an
 image with caption or add third "popup button" to images that would
 add/remove captions directly without needing to open the uploader/gallery
 popup.

--

Comment:

 Replying to [comment:14 sushkov]:
 > @jeremyclarke has a point when says that image caption content should go
 between [caption] shortcode tags.

 Don't think changing the structure of the image caption shortcode is
 possible. This would break all plugins and themes that use it directly (we
 explicitly allow that in `img_caption_shortcode()` with the
 `'img_caption_shortcode'` filter).

 I rather see that as escaping all quotes or encoding the html string in
 caption="...", whichever works better. If we need to encode it, we can
 decode before running the `'img_caption_shortcode'` filter to keep it
 back-compat.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18311#comment:16>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list