Make WordPress Core

Opened 9 years ago

Last modified 3 years ago

#31375 new defect (bug)

Image caption with heading adds an empty paragraph at page edits

Reported by: sweman's profile sweman Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.1
Component: Editor Keywords: needs-patch
Focuses: Cc:

Description

Hi,

I'm experiencing a problem when trying to use heading tags within image captions. Upon inserting (or editing) the image on a page, I wrote a heading before a block of text in the caption. The whole thing would look something like this:

<h3>Heading here</h3>A block of text directly following the heading.

What happens is that every time I edit the page in any way (not even touching the image or image caption) there is an extra empty paragraph added to the caption text. That means that anything below the caption jumps one line further down at every edit.

Just to see if this is some plugin conflict, I created a clean WordPress install without plugins, and tried the same thing. The problem was reproduced. Looking at the html code generated, there is a new <p></p> added at every page edit, and sometimes a couple of <br /> are inserted before the heading tags. Here is a link to my test site:

http://dev.webbkoncept.se/themetest/

I tried it using both themes twenty fourteen and twenty fifteen, experiencing the same bug.

Change History (3)

#1 follow-up: @janhenckens
9 years ago

  • Component changed from General to Editor

Thanks for the ticket sweman! I can reproduce this by doing what you described above.

When I look at the text editor, a caption without markup looks like this (no matter how many times the post is saved):

[caption id="attachment_40" align="alignright" width="400"]<img class="size-full wp-image-40" src="http://core.local.onedge.be/wp-content/uploads/2015/02/foo.gif" alt="Foo!" width="400" height="400" /> Foo![/caption]

When an h3 tag the code looks the same, until you save it in the visual editor:

[caption id="attachment_40" align="alignright" width="400"]<img class="size-full wp-image-40" src="http://core.local.onedge.be/wp-content/uploads/2015/02/foo.gif" alt="Foo!" width="400" height="400" /><h3>Foo!</h3>&nbsp;[/caption]

And every time you save in the Visual editor, another &nbsp; gets added.

When we do the same thing in the text editor, the problem does not present itself.
So this looks like an issue within the Editor or even in TinyMCE?

#2 in reply to: ↑ 1 @sweman
9 years ago

Replying to janhenckens:

Thanks for the ticket sweman! I can reproduce this by doing what you described above.

When I look at the text editor, a caption without markup looks like this (no matter how many times the post is saved):

[caption id="attachment_40" align="alignright" width="400"]<img class="size-full wp-image-40" src="http://core.local.onedge.be/wp-content/uploads/2015/02/foo.gif" alt="Foo!" width="400" height="400" /> Foo![/caption]

When an h3 tag the code looks the same, until you save it in the visual editor:

[caption id="attachment_40" align="alignright" width="400"]<img class="size-full wp-image-40" src="http://core.local.onedge.be/wp-content/uploads/2015/02/foo.gif" alt="Foo!" width="400" height="400" /><h3>Foo!</h3>&nbsp;[/caption]

And every time you save in the Visual editor, another &nbsp; gets added.

When we do the same thing in the text editor, the problem does not present itself.
So this looks like an issue within the Editor or even in TinyMCE?

Yes, that's a good description of the problem! I'm not a programmer so I really have no idea what could be the cause or anything though.

#3 @noisysocks
3 years ago

  • Keywords needs-patch added
Note: See TracTickets for help on using tickets.