When I have multiple WYSIWYG textareas on a node and add media to one of them, that textarea appears blank. The data is still on the node, and appears when I click the "Disable rich-text" link.

This is happening because the 'attach' method of Media's WYSIWYG plugin is failing. Drupal.settings.tagmap shouldn't have multiple values for some media filter tags, but it does. The attached patch fixes this by moving the static variable behavior from _media_generate_tagMap() to media_pre_render_text_format().

CommentFileSizeAuthor
media-tagmap.patch3.7 KBbecw

Comments

JacobSingh’s picture

Firstly, you rock.
Secondly, everyone at Acquia is psyched to see you active in the issue queue. Sorry I haven't had a chance to properly review this. James.Elliot took a look w/ me yesterday / today and It looks like an obvious fix and a really stupid bug. the tagMap stuff is kinda a mess anyway. We could commit it like this, but I'm thinking we might want to fix this in a different way.

I don't mean refactoring it entirely, but it seems like the setting should at the very least be scoped under settings.media.tagMap, but really should be in settings.media.tagMaps[id_of_field] right? That should kinda eliminiate this problem in a cleaner, easier to read way if each field only needed to read the map of media meant for that field.

Whattya think?

becw’s picture

Well, I agree, and it was definitely tempting to rewrite the tagmap stuff more comprehensively--but this patch makes it work and touches a single discrete section of code, so I figured it would be easier to review and test, and ultimately my goal is to make existing functionality work, first--all code always needs a rewrite.

But yes: the js tagmap should be scoped more carefully, and at some point the wysiwyg plugin code could be refactored.

becw’s picture

Status: Needs review » Fixed

This issue is no longer present in the latest dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.