Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#28756 closed defect (bug) (fixed)

wp_editor issues when used in frontend (TinyMCE)

Reported by: m-bp's profile M-BP Owned by: azaozz's profile azaozz
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.9.1
Component: TinyMCE Keywords:
Focuses: javascript Cc:


When using the wp_editor in the frontend multiple issues occur (in trunk as well as 3.9.1):

  1. when wp_editor is used with its default configuration, gallery shortcodes do not get replaced by the images they represent, for single images this is the case - bug or intended behavior?
  1. to replace the shortcodes with a placeholder the TinyMCE plugin wpgallery can be used. This works fine. However, when such a post/wp_editor field is then edited (or just after it is submitted), TinyMCE itself converts the gallery into single images but they cannot be edited anymor. They are no longer treated as a gallery but instead as single images.
  1. with the plugin wpgallery active, on edits (or after the form is submitted) "> shows above all gallery images. See the below markup (see the superfluous "> in between):
<a class="wp-media mceItem wp-gallery" data-mce-href="http://localhost/wordpress/wp-content/uploads/2014/07/19.jpg" data-mce-placeholder="1" data-wp-media="%5Bgallery-1%5D" rel="prettyPhoto<img src=" href="http://localhost/wordpress/wp-content/uploads/2014/07/19.jpg">
<img class="attachment-thumbnail" width="200" height="200" data-mce-src="http://localhost/wordpress/wp-content/uploads/2014/07/19-200x200.jpg" alt="19" src="http://localhost/wordpress/wp-content/uploads/2014/07/19-200x200.jpg">

I have tried all possible TinyMCE settings and plugin combinations but these issues persist. I also tried to use JS to regex the "> away but unfortunately to no avail.

I think a possible fix would be to prevent TinyMCE from converting the gallery shortcode into single images in the frontend and simply leave wpgallery do its thing, namely adding its placeholder which works ok.

Attachments (1)

screenshot.png (113.2 KB) - added by M-BP 10 years ago.
Screenshot for illustration

Download all attachments as: .zip

Change History (5)

10 years ago

Screenshot for illustration

#1 @DrewAPicture
10 years ago

  • Component changed from General to Editor

#2 @azaozz
10 years ago

  1. To see gallery previews when wp_editor() is used on the front-end, you'll need to wp_enqueue_script('mce-view'); separately as this is still experimental and will probably change in 4.1. Testing it and fixing any edge cases on the front-end welcome :)
  1. When the 'wpview' TinyMCE plugin is not loaded, the 'wpgallery' plugin uses a gallery placeholder (as before). To edit a gallery that was replaced by a placeholder the media components will have to be loaded (as editing uses the media modal), then double-click on the placeholder. We can improve this a bit: need to confirm that both 'wpview' and wp.mce.views exist or use a placeholder.
  1. The problem here is: rel="prettyPhoto<img src=" href="http://localhost/wordpress/wp-content/uploads/2014/07/19.jpg">". Not sure how this (broken) attribute got there, nothing in WordPress would add it.

#3 @azaozz
10 years ago

  • Component changed from Editor to TinyMCE
  • Milestone changed from Awaiting Review to 4.1

Setting to 4.1 to fix point 2 above.

#4 @azaozz
10 years ago

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

In 29883:

TinyMCE: fix the 'wpgallery' plugin to use a placeholder for galleries when either the 'wpview' plugin or wp.mce is not loaded. Fixes #28756

Note: See TracTickets for help on using tickets.