The Media WYSIWYG integration stores file information in the database in a custom format like this:
[[{"type":"media","view_mode":"media_large","fid":"50151","attributes":{"alt":"","class":"media-image","height":"108","typeof":"foaf:Image","width":"480"}}]]
When the edit form loads the Media text processor loads some custom JS to make the WYSIWYG editor convert this to something like this:
<span id="styles-1-0" class="media-image media-element file-media-large" data-file_info="%7B%22type%22:%22media%22,%22view_mode%22:%22media_large%22,%22fid%22:%2250151%22%7D"> <img id="1" src="http://example.com/files/styles/medium/public/something.png" alt="" /></span>
The problem happens when the user changes the text filter to a text format that doesn't have WYSIWYG enabled, the WYSIWYG editor is removed (obviously) and the HTML code above is then saved into the database instead of the [[{"type":"media"....}]] code.
Comments
Comment #1
dave reidIs this a problem unique to Media or is this a problem that all WYSIWYG plugins that convert markup to HTML would have when the text format is changed like this?
Comment #2
damienmckenna@Dave: Not sure, I don't have any other plugins installed that do what the Media integration does.
I think part of the issue may come down to a philosophical question: should the Drupal.wysiwyg.plugins.media.detach() function be triggered when the text format is changed and the WYSIWYG editor disabled, thus convert the embedded image to JSON format, or should it be left in the custom HTML format?
Comment #3
damienmckennaI might just need to write a small script to fix content that gets borked like this.
Comment #4
chris matthews commentedClosing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team