Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#31403 closed defect (bug) (fixed)

Hardcoded Id in WP 4.1.1 Wpeditimage

Reported by: programmin Owned by:
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.1
Component: TinyMCE Keywords: needs-patch
Focuses: ui, javascript Cc:


As of WP4.1.1 the wpeditimage plugin is referencing the editor element as:

iframe = document.getElementById( editor.id + '_ifr' );

This is less portable than the previous reference, and hard-codes a reference to an iframe id that doesn't exist in MCE Inline mode.

For cases where we use MCE in an Inline mode, it would be great to have a filter (perhaps a jQuery.trigger with an object by reference?) to set the outer bounds or the element ("iframe" in current code) wpeditimage should use.

Change History (8)

#1 @iseulde
7 years ago

For reference: [31180].

#2 @iseulde
7 years ago

Not sure if the code was that portable before. The first element of the 'ContentAreaContainer' would need to have no dimensions in inline mode. I'm also pretty sure we look for an iframe in other plugins. Worth investigating though.

#3 @programmin
6 years ago

Looks like it's worse in 4.3 RC, a bunch of code in wp-includes/js/tinymce/plugins/wordpress/plugin.js was changed to be dependent on the id_ifr element:

mceIframe = document.getElementById( editor.id + '_ifr' ),

Could this possibly be reworked for a more inline-friendly version? Was this rewritten for MCE 4.2?

I'm surprised it would be changed to this because getElementById only works if the specific element is in the DOM of the page, never if it has been removed at the moment.

#4 @iseulde
6 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Could this possibly be reworked for a more inline-friendly version?

Yes. Currently it only works in an iframed editor and it would be great to support inline too.

Do you have an example configuration?

#5 @iseulde
6 years ago

  • Version changed from 4.1.1 to 4.1

#6 @iseulde
6 years ago

I believe this was fixed in [33592]. Please reopen if this is not the case.

#7 @iseulde
6 years ago

  • Milestone changed from Future Release to 4.3
  • Resolution set to fixed
  • Status changed from new to closed

#8 @programmin
6 years ago

I don't think so. See wp-includes/js/tinymce/plugins/wordpress/plugin.js:

var Factory = tinymce.ui.Factory,
			settings = editor.settings,
			container = editor.getContainer(),
			wpAdminbar = document.getElementById( 'wpadminbar' ),
			mceIframe = document.getElementById( editor.id + '_ifr' ),

So still referencing an (id)_ifr and expecting it to be an iframe (not inline-mode-friendly), and also expecting a #wpAdminbar element (what if you want to use the plugin in an editor that's not on /wp-admin/ page??)

Note: See TracTickets for help on using tickets.