WordPress.org

Make WordPress Core

Opened 17 months ago

Last modified 8 weeks ago

#22458 new defect (bug)

Image captions and block level elements

Reported by: trepmal Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.4
Component: Media Keywords:
Focuses: Cc:

Description

After accidentally putting a captioned image inside another image's caption (yo dawg), I found that block level elements in general seem to not play well.

[caption id="attachment_809" width="150" align="alignnone"]<a href="#"><img width="150" height="150" src="http://colorto.me/png/150/rand" class="size-thumbnail wp-image-809" /></a> tree<p>block level in caption</p>[/caption] 

With <p> tag: Toggling about 3 times completely removes the tag, contents remain

[caption id="attachment_809" width="150" align="alignnone"]<a href="#"><img width="150" height="150" src="http://colorto.me/png/150/rand" class="size-thumbnail wp-image-809" /></a> tree<div>block level in caption</div>[/caption] 

With <div> tag: Toggling about 2 times causes the entire caption to be removed, after first adding some unbalanced <dd> and <dl> after the first toggle

[caption id="attachment_809" width="150" align="alignnone"]<a href="#"><img width="150" height="150" src="http://colorto.me/png/150/rand" class="size-thumbnail wp-image-809" /></a> tree<ul><li>block level in caption</li></ul>[/caption] 

With <ul><li> tags: First toggle will 'organize' your list tags, each toggle after that adds 2 <br /> tags and wraps an extra <ul> around the list.

Change History (4)

comment:1 trepmal17 months ago

  • Component changed from General to Media

comment:2 trepmal17 months ago

  • Version set to 3.4

If block levels tags aren't supported in captions, can it break consistently? Or with valid html?

comment:3 ircbot8 weeks ago

This ticket was mentioned in IRC in #wordpress-dev by DH-Shredder. View the logs.

comment:4 DH-Shredder8 weeks ago

  • Milestone changed from Awaiting Review to Future Release

Chatted with @azaozz on this a bit in the chat log linked above.

Currently, we don't officially support block level elements in captions due to conflicts between MCE's cleanup, and browser quirks.

However, since users can unwittingly paste the text in as a caption within MCE's popup, it'd be good to at least make the experience consistent.

Note: See TracTickets for help on using tickets.