Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#28951 closed defect (bug) (fixed)

Caption shortcode `class` attribute stripped by TinyMCE

Reported by: dominicp's profile dominicp Owned by: azaozz's profile azaozz
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.9.1
Component: Editor Keywords: dev-feedback has-patch
Focuses: javascript, administration Cc:

Description (last modified by SergeyBiryukov)

A class attributed is listed as supported in the Codex and it looks like support was added in [27404]. But, if I add one manually in text view, and switch back to the visual editor, the attribute is stripped.

Unfortunately, I'm not familiar enough with the WP internal javascript to pinpoint exactly where this is happening.

Attachments (2)

28951.diff (3.0 KB) - added by knutsp 10 years ago.
Keep the caption shortcode class attribute in TinyMCE
28951.2.diff (3.6 KB) - added by kadamwhite 10 years ago.
Alter existing patch to use "align" instead of "aln", and make alignment class regex case-insensitive

Download all attachments as: .zip

Change History (13)

#1 @SergeyBiryukov
10 years ago

  • Description modified (diff)

#2 @SergeyBiryukov
10 years ago

  • Keywords needs-patch added

Confirmed.

@knutsp
10 years ago

Keep the caption shortcode class attribute in TinyMCE

#3 @knutsp
10 years ago

  • Keywords dev-feedback added; needs-patch removed

This is my first patch touching Javascript. Not sure this approach is acceptable, but worth a try.

#4 @knutsp
10 years ago

  • Keywords has-patch added

#5 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 4.0

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


10 years ago

#7 @DrewAPicture
10 years ago

  • Owner set to azaozz
  • Status changed from new to reviewing

This looks pretty good at a glance. If we're gonna introduce a new var here, can we at least use a complete word instead of another cryptic abbreviation? Any input @azaozz?

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


10 years ago

@kadamwhite
10 years ago

Alter existing patch to use "align" instead of "aln", and make alignment class regex case-insensitive

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


10 years ago

#10 @kadamwhite
10 years ago

This patch looks good, but I've altered the name of the new variable to be align (for readability); made the regex for the alignment class case-insensitive; and standardized the whitespace around + operators within the lines touched by the path.

The reasoning for making the regex case-insensitive is that putting in mis-cased values into the 'align' attribute was causing an issue where the invalid attribute value and "wp-class" would get inserted into the user's shortcode class attribute value. Invalid alignment values (e.g. align="sideways") will still trigger this behavior, and that may be inevitable, but making the regex case-insensitive was a quick way to mitigate it without altering the functionality of the patch.

Last edited 10 years ago by kadamwhite (previous) (diff)

#11 @azaozz
10 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In [29380]:

TinyMCE: add support for class attribute on the caption shortcode. Part props knutsp, kadamwhite, fixes #28951.

Note: See TracTickets for help on using tickets.