Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#25700 closed defect (bug) (fixed)

Images with Captions

Reported by: wpranger's profile WPRanger Owned by: nacin's profile nacin
Milestone: 3.7.1 Priority: normal
Severity: normal Version: 3.7
Component: TinyMCE Keywords: has-patch
Focuses: Cc:

Description

WordPress 3.7

New captioned image inserted into the Visual Editor produces a huge data-mce-style width (10000px+) moving the inserted image out of the editor viewable area.

Attachments (1)

25700-1.diff (759 bytes) - added by LucP 10 years ago.
proposed fix

Download all attachments as: .zip

Change History (22)

#1 @SergeyBiryukov
10 years ago

  • Component changed from General to TinyMCE
  • Version set to 3.7

#2 @LucP
10 years ago

Just tested and yeah; it's quite an ugly one... I think i've found the problem in wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js I'll create a patch...

#3 @LucP
10 years ago

The error is caused by the minification of the editor_plugin_src.js file:

This code (which returns a perfectly normal caption-box:

<dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+( 10 + parseInt(w) )+'px">

gets turned into this when it's minified:

<dl id="'+d+'" class="wp-caption '+e+'" style="width: 10'+parseInt(f)+'px">

I'd love to create a patch for this, but I have no idea where the minification of this file is taking place?

@LucP
10 years ago

proposed fix

#4 @LucP
10 years ago

This patch should fix the problem. Every variable in that html-string gets generated before it gets mixed with the html, I think it's a lot cleaner to do it like this.

	w = parseInt( w ) + 10;

	return '<div class="'+div_cls+'"><dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+w+
	'px"><dt class="wp-caption-dt">'+img+'</dt><dd class="wp-caption-dd">'+cap+'</dd></dl></div>';

#5 @LucP
10 years ago

  • Keywords has-patch added

#6 follow-up: @La Geek
10 years ago

@patch test: Does not work

Unfortunately this patch does not work for me (I emptied cache). In google+ has been mentioned that Tiny MCE Advanced has no problems with captions (with recent Tiny MCE Advanced Update) and 3.7.

Perhaps this helps.

Last edited 10 years ago by La Geek (previous) (diff)

#7 @toscho
10 years ago

  • Cc info@… added

#8 in reply to: ↑ 6 @LucP
10 years ago

Replying to La Geek:

@patch test: Does not work

Unfortunately this patch does not work for me (I emptied cache).

Did you run the patch 'as-is', because the original minified javascript that caused the error will probably still be included; Like I mentioned... I have no idea what to use to minify this file and i don't think we should patch minified core files...

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

#9 @La Geek
10 years ago

I applied the patch to editor_plugin_src.js and I removed the original editor_plugin.js (for test) Then I copied the patched editor_plugin_src.js and renamed this file to editor_plugin.js.

So both files were patched. Does it work for you with this patch?

#11 @azaozz
10 years ago

The patch is good. The problem is that latest UglifyJS failed when minifying the original file.

#12 @nacin
10 years ago

#25708 was marked as a duplicate.

#13 @La Geek
10 years ago

The patch is good. The problem is that latest UglifyJS failed when minifying the original file.

How it can be then, when I used the patched file twice, once as editor_plugin_src.js and then as editor_plugin.js, that it does not work? I used in both case a non minified version. So UglifyJS did not minify anything.

I applied the patch to a 3.7 version (not github version).

#14 @nacin
10 years ago

  • Milestone changed from Awaiting Review to 3.7.1

#15 @nacin
10 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 25921:

3.7 regression: Fix the width of captioned images inserted into the visual editor.

Pulls some arithmetic outside of some string concatenation to avoid a nasty uglify.js regression: https://github.com/mishoo/UglifyJS2/pull/330.

props LucP.
fixes #25700 for trunk.

#16 @nacin
10 years ago

In 25922:

3.7 regression: Fix the width of captioned images inserted into the visual editor.

Pulls some arithmetic outside of some string concatenation to avoid a nasty uglify.js regression: https://github.com/mishoo/UglifyJS2/pull/330.

Merges [25921] to the 3.7 branch.

props LucP.
fixes #25700.

#17 @johnbillion
10 years ago

#25713 was marked as a duplicate.

#18 @joneiseman
10 years ago

I tried making this code change to wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js but it didn't fix the problem for me.

#19 @azaozz
10 years ago

...it didn't fix the problem for me.

The error in only in the minified editor_plugin.js file which is inside wp-tinymce.js.gz. To test this you can download wp-tinymce.js.gz from http://core.svn.wordpress.org/branches/3.7/wp-includes/js/tinymce/ and replace it in your install (don't forget to refresh the browser cache).

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

#20 @azaozz
10 years ago

In 25943:

Bump the (cache-busting) TinyMCE version for 3.7, see #25700.

#21 @azaozz
10 years ago

In 25944:

Bump the TinyMCE version for 3.8, see #25700.

Note: See TracTickets for help on using tickets.