Problem/Motivation

The introduced media wrappers from #1970370-3: Split media token handling from WYSIWYG integration javascript make more trouble than they actually solve.
The idea was to be able to insert multiple / nested HTML-tags as media "placeholder" into a WYSIWYG editor. Unfortunately the current WYSIWYG integrations aren't capable to handle such constructs as single "element" - even worse the placeholder that was before a single HTML-tag (<img />) consists now of multiple tags / directives (<!--MEDIA-WRAPPER-START-1--><img><!--MEDIA-WRAPPER-START-2-->).
Another issue introduced with the mentioned patch is that updates on the placeholder element (e.g. a resize) aren't reflected in the tagmap because it always falls back to the existing tagmap item instead creating a new one (Introduced in #1970370-2: Split media token handling from WYSIWYG integration javascript).

Proposed resolution

Basic conditions:

  • The placeholder element in the basic WYSIWYG integration has to be a single html-tag e.g. an image.
    More complex scenarios can be achieved by using the already existing module media_wysiwyg_view_mode.
  • Changes on this placeholder element have to be reflected in the tagmap / in the media token that's stored.

The attached patch reverts the parts that cause the trouble and changes media_file_displays_alter() to ensure the returned placeholder is a single html tag - at least for images.

Remaining tasks

  • Figure out how we can generically ensure that a WYSIWYG placeholder is a single html tag. Shall we introduce a dedicated view mode? I think that would be more predictable.

User interface changes

none

API changes

none

#2067063: Wysiwyg integration is broken
#1970370: Split media token handling from WYSIWYG integration javascript
#2067325: [META] Tracking WYSIWYG compatibility
#2107465: IE removes MEDIA-WRAPPER-START comment
#2120471: TinyMCE plugin does not put the inserted image in the right place in IE
#2062659: Roll the media_wysiwyg_view_mode module into media module.
#2090979: Media once inserted via WYSIWYG cannot be delete anymore
#2116639: Multiple items inside Media tagmap variables makes it broken. (I think)
#1504696: Integration with CKEditor module

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ParisLiakos’s picture

yes please. reverting will fix a good hunk of #2067063: Wysiwyg integration is broken

+++ b/js/media.filter.js
@@ -22,7 +22,7 @@
-          var index = $.inArray(macro, matches);
+          var index = matches.indexOf(macro);

you essentially revert #2108647: Array.indexOf doesn't exist!

das-peter’s picture

you essentially revert #2108647: Array.indexOf doesn't exist!

Oh, that's not the idea ;) Re-rolled patch attached.

kaidjohnson’s picture

@das-peter, we've done away with the media wrappers in #2067063: Wysiwyg integration is broken and have taken a different approach to element match & replace (no jquery, no regex). It would be great to get your input on that thread, as it should resolve this issue once complete.

kaidjohnson’s picture

Issue summary: View changes

Added another related issue.

ParisLiakos’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)

the issue linked above has more exposure, lets move on there instead