There seems to be an issue with embedding some provider content such as Twitter and Facebook from the media browser in the wysiwyg. When attempting to insert the media item from the media browser on the view mode selection pop up I'm getting the following js error: Uncaught TypeError: Cannot read property 'match' of undefined, which prevents me from submitting the form. See attached screenshot. The error is produced from css.match in the following code:

if (info.view_mode) {
  // Remove any existing view mode classes.
  element.removeClass (function (index, css) {
    return (css.match (/\bfile-\S+/g) || []).join(' ');
  });
  classes.push('file-' + info.view_mode.replace(/_/g, '-'));
}
// Check for alignment info, after removing any existing alignment class.
element.removeClass (function (index, css) {
  return (css.match (/\bmedia-wysiwyg-align-\S+/g) || []).join(' ');
});

I'm not quite sure how to get around this limitation.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adam-delaney created an issue. See original summary.

adam-delaney’s picture

Issue summary: View changes
adam-delaney’s picture

Issue summary: View changes

There are actually 2 offending lines in media_wysiwyg.filter.js in the media module that prevents the form submission for the media browser for certain providers. Both are returning the same error.

      if (info.view_mode) {
        // Remove any existing view mode classes.
        element.removeClass (function (index, css) {
          console.log(element);
          return (css.match (/\bfile-\S+/g) || []).join(' ');
        });
        classes.push('file-' + info.view_mode.replace(/_/g, '-'));
      }
      // Check for alignment info, after removing any existing alignment class.
      element.removeClass (function (index, css) {
        return (css.match (/\bmedia-wysiwyg-align-\S+/g) || []).join(' ');
      });
Devin Carlson’s picture

Project: Media: oEmbed » D7 Media

This code lives in the Media module, not Media: oEmbed.

joseph.olstad’s picture

Status: Active » Postponed (maintainer needs more info)

this might be fixed in the latest release. 7.x-2.8 or maybe 7.x-2.6

almunnings’s picture

This can be replicated by turning $conf['theme_debug'] to true inside settings.php

Seems in media_wysiwyg.filter.js, element = element.children(); is picking up the comments and text nodes.

joseph.olstad’s picture

Status: Postponed (maintainer needs more info) » Fixed

Thanks!

joseph.olstad’s picture

Component: Code » Documentation
Category: Bug report » Support request

Generally, theme debug turned on is only used for debugging, expect some advanced functionality to break.
Workaround is to disable theme debug as mentioned. You should NEVER have this enabled on a production site unless momentarily, normally you'd do the debugging on a development copy of the site.

Status: Fixed » Closed (fixed)

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

criznach’s picture

I'm still seeing this in the latest 7.x-2.18+1-dev. I do not set $conf['theme_debug'], and drush shows the default of FALSE

drush vget theme_debug
theme_debug: false

media_wysiwyg.filter.js?p7stfi:287 Uncaught TypeError: Cannot read property 'match' of undefined
at Comment. (media_wysiwyg.filter.js?p7stfi:287)
at Comment. (jquery.min.js?v=1.5.2:16)
at Function.each (jquery.min.js?v=1.5.2:16)
at $.fn.init.each (jquery.min.js?v=1.5.2:16)
at $.fn.init.removeClass (jquery.min.js?v=1.5.2:16)
at Object.create_element (media_wysiwyg.filter.js?p7stfi:286)
at Object.replaceTokenWithPlaceholder (media_wysiwyg.filter.js?p7stfi:60)
at Object.attach (wysiwyg-media.js?p7stfi:77)
at CKEDITOR.htmlDataProcessor.toHtml (ckeditor-3.0.js?p7stfi:100)
at $.setData (ckeditor.js?p7stfi:774)