Make WordPress Core

Opened 12 years ago

Closed 8 years ago

#22458 closed defect (bug) (invalid)

Image captions and block level elements

Reported by: trepmal's profile trepmal Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: TinyMCE 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 (7)

#1 @trepmal
12 years ago

  • Component changed from General to Media

#2 @trepmal
12 years ago

  • Version set to 3.4

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

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


11 years ago

#4 follow-up: @kirasong
11 years 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.

#5 in reply to: ↑ 4 @ericlewis
11 years ago

Replying to DH-Shredder:

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.

If we don't officially support block level elements in captions, should we strip them from the caption field on change? Or on "Insert into post" click?

#6 @iseulde
10 years ago

  • Component changed from Media to TinyMCE

#7 @azaozz
8 years ago

  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from new to closed

This behavior has changed which makes this ticket invalid now. If block elements are pasted in a caption they are removed and <br> inserted instead.

Note: See TracTickets for help on using tickets.