This might be related to #1970370: Split media token handling from WYSIWYG integration javascript and #2066859: Removed media are restored on save in WYSIWYG
When inserting an image with WYSIWYG and Media the image gets wrapped into:
<!--MEDIA-WRAPPER-START-1--><img src="I-am-the-placeholder" /><!--MEDIA-WRAPPER-END-1-->
Whenever I try to update e.g. the title tag of the image in chrome through the media popup the wrapper tags get messed up to
<!--MEDIA-WRAPPER-START-2--><img src="I-am-the-placeholder" /><!--MEDIA-WRAPPER-END-2--><!--MEDIA-WRAPPER-END-1-->
so the trailing MEDIA-WRAPPER-END tag is still there, BUT updating still works (as it's just interpreted as a comment from now on).
In Firefox it's different, after updating I get something like
<p><!--MEDIA-WRAPPER-END-1--><!--MEDIA-WRAPPER-START-2--><img src="I-am-the-placeholder" /><!--MEDIA-WRAPPER-END-2--></p>
<p><!--MEDIA-WRAPPER-END-1--></p>
When saving or switching to source code 'replacePlaceholderWithToken' in media.filter.js will swap the outer old wrapper with ID 1 with the old markup which is still linked in 'Drupal.settings.tagmap'. This results in the old macro being filled in. This doesn't happen in chrome as the outer wrapper is not fully intact. I tracked it further to wysiwyg/js/ckeditor-3.0.js > addPlugin > pluginCommand at around line 195. 'editor.getSelection()' seems to return the wrong object, it doesn't seem to contain the full (chrome) or any (FF) wrapper tags, which I think it should to be later able to replace it through the 'insert' call 'Drupal.wysiwyg.instances[this.instanceId].insert(markup)' in wysiwyg.media.js.
Am not sure if this is caused in WYSIWYG itself, in CKEditor, in media or in the integration. Am using CKEditor 3.6.6.1
I would appreciate any hints.
Comments
Comment #1
twodMedia is part to blame, Wysiwyg module is part to blame (for not providing better selection control), but mostly it's because placeholders in WYSIWYG situations are basically a pain to work with. See #2028253-3: If you change a file's information with the WYSIWYG disabled, re-enabling the WYSIWYG loses the file.
Comment #2
ti2m commentedQuick as always, thanks for the feedback! That clears things up, bit of a more complex problem.
Comment #3
kaidjohnson commentedWe're addressing this issue in https://drupal.org/node/2067063 as it is related to how attributes persist between the WYSIWYG and the front-end rendering.