Make WordPress Core

Opened 14 years ago

Closed 12 years ago

Last modified 12 years ago

#12464 closed defect (bug) (duplicate)

Text links are stripped from image captions

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

Description

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 12 years ago.
12464.2.diff (1.3 KB) - added by ericlewis 12 years ago.
Fix replace ' instead of ' for single quotes in [caption] string

Download all attachments as: .zip

Change History (19)

#1 @simonlawrence
14 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:

http://www.priceplow.com/wordpress-link-in-image-caption
http://www.transformationpowertools.com/wordpress/hyperlinks-in-wordpress-image-captions
http://blogwip.com/images/adding-linked-captions-images-wordpress/

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:

h=h.replace(/<\S[^<>]*>/gi,"").replace(/'/g,"&#39;").replace(/"/g,"&quot;");

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

#2 @dnusim
14 years ago

  • Cc wordpress-thomas@… added

#3 @nacin
14 years ago

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

#4 @dnusim
14 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
14 years ago

  • Keywords needs-patch added

#6 @wojtek.szkutnik
14 years ago

  • Keywords gsoc added

#7 @dnusim
14 years ago

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

#8 @blepoxp
14 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
13 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
13 years ago

  • Milestone changed from 3.1 to Future Release

#11 @jane
12 years ago

  • Milestone changed from Future Release to 3.4

#12 @anointed
12 years ago

  • Cc anointed added

#13 @DrewAPicture
12 years ago

  • Cc xoodrew@… added

@ericlewis
12 years ago

#15 @ericlewis
12 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.

@ericlewis
12 years ago

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

#16 @ericlewis
12 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 12 years ago by nacin (previous) (diff)

#17 @nacin
12 years ago

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