diff --git a/js/wysiwyg-media.js b/js/wysiwyg-media.js
index 96d8d70..97697f0 100644
--- a/js/wysiwyg-media.js
+++ b/js/wysiwyg-media.js
@@ -165,15 +165,19 @@ Drupal.wysiwyg.plugins.media = {
* Detach function, called when a rich text editor detaches
*/
detach: function (content, settings, instanceId) {
- var content = $('
' + content + '
');
- $('img.media-image',content).each(function (elem) {
- var tag = Drupal.wysiwyg.plugins.media.createTag($(this));
- $(this).replaceWith(tag);
- var newContent = content.html();
- var tagContent = $('').append($(this)).html();
- Drupal.settings.tagmap[tag] = tagContent;
- });
- return content.html();
+ // Replace all Media placeholder images with the appropriate inline json
+ // string. Using a regular expression instead of jQuery manipulation to
+ // prevent