Make WordPress Core

Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#12464 closed defect (bug) (duplicate)

Text links are stripped from image captions

Reported by: dnusim Owned by: azaozz
Milestone: Priority: normal
Severity: normal Version: 2.9.2
Component: TinyMCE Keywords: needs-patch gsoc
Focuses: Cc:


Basic HTML, like text links, should be allowed in image captions. Links are now stripped from the captions.

Text links in the image caption would be the most logical way to credit the photographer. In some cases, a link to the license covering the image is also mandatory. Creative Commons-licensed images are a great example of this.

Attachments (2)

12464.diff (1.3 KB) - added by ericlewis 9 years ago.
12464.2.diff (1.3 KB) - added by ericlewis 9 years ago.
Fix replace ' instead of ' for single quotes in [caption] string

Download all attachments as: .zip

Change History (19)

#1 @simonlawrence
11 years ago

  • Cc simonlawrence added

When you use the visual editor to add a link to the caption text it is stripped out when saving but you can edit the caption attribute in the HTML view and it will save.

I have found several people talking about it:


Looking through the code and it appears to be the "wpeditimage" TinyMCE JavaScript plugin that is replacing all HTML tags in the contents of the caption attribute:


from /wp-includes/js/tinymce/wp-tinymce.php

#2 @dnusim
11 years ago

  • Cc wordpress-thomas@… added

#3 @nacin
11 years ago

  • Component changed from Gallery to TinyMCE
  • Milestone changed from Unassigned to Future Release
  • Owner set to azaozz

#4 @dnusim
11 years ago

  • Milestone changed from Future Release to 3.1

As it turns out: Links with singly-quoted attributes are only stripped if you are using the visual editor (in WP 2.9.2). If you are using the basic (HTML) editor, they are instead escaped before inserting them into the shortcode, which works fine.

I'm guessing a solution would involve doubly-quoted attributes being made singly-quoted before they are escaped, as I'm guessing the double quotes mess up the way shortcodes work. On top of that we need to figure out why the visual editor doesn't give the same result as the basic editor.

Changing milestone to 3.1 as this seems to affect a lot of people.

#5 @dnusim
11 years ago

  • Keywords needs-patch added

#6 @wojtek.szkutnik
11 years ago

  • Keywords gsoc added

#7 @dnusim
11 years ago

This issue seems to be resolved in trunk. If someone will confirm, I think we can close this.

#8 @blepoxp
11 years ago

Single quotes work in HTML mode. Double quotes in HTML mode (escaped or not) break the caption if caption="..." uses double quotes. Tags are stripped if you use the caption field in the Image GUI but the caption still works.

#9 @nacin
10 years ago

  • Milestone changed from Awaiting Triage to 3.1

I thought this was going to happen in 3.1 with the TinyMCE update. Moving there just because I think there might be a duplicate ticket or some code somewhere. Otherwise, punt.

#10 @ryan
10 years ago

  • Milestone changed from 3.1 to Future Release

#11 @jane
9 years ago

  • Milestone changed from Future Release to 3.4

#12 @anointed
9 years ago

  • Cc anointed added

#13 @DrewAPicture
9 years ago

  • Cc xoodrew@… added

9 years ago

#15 @ericlewis
9 years ago

I'm not sure if this is perfect, but I think a step in the right direction here. This patch helps with adding links to captions in the visual editor mode.

The issue with links in the visual editor is that captions have all HTML entities filtered out of them. The patch filters out only non-anchor tags, leaving anchors there.

The other issue is the caption shortcode holds the text for caption between double quotes. To deal with this all quotes within the caption are converted to single quotes.

9 years ago

Fix replace ' instead of &#39; for single quotes in [caption] string

#16 @ericlewis
9 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

This has at this point been taken care of in #18311

Last edited 9 years ago by nacin (previous) (diff)

#17 @nacin
9 years ago

  • Milestone 3.4 deleted
Note: See TracTickets for help on using tickets.