Embedding swf in Drupal Nodes

I'm currently working on a project where I need to embed .swf movies in a Drupal 5 node via TinyMCE. I'm using D5.x.dev CVS and the TinyMCE 5.x-1.9. What I thought would be an easy mission turned out to be lots of reasearch with a simple solution. I'm not certain if this is applicable to the WYSIWYG API (which i like very much). I did not have the luxury of being able to swap out any modules.

 

The core of the problem was by default TinyMCE 5.x.1-9 module does not have the media plugin enabled. Additionally it also strips out the HTML embed tag.

 

Enabling the media module is easy. You will need to edit (and fork) the module, as I can't find a way to override the loaded modules via a theme hook.

 

In plugin_reg.php add the following:

$plugins['media'] = array();
$plugins['media']['theme_advanced_buttons2'] = array('media');
$plugins['media']['extended_valid_elements'] = array('object[type|data|width|height|classid|codebase]','param[name|value]','embed[src|type|width|height|flashvars|wmode]');

Also make sure to enable the "Media" button in the TinyMCE config. The next problem took be a while to figure out. TinyMCE would keep stripping out the tag. I search for hours. The kicker is you need to add a theme hook that sets the media_strict parameter to false.

function mytheme_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
  if (isset($init)) {
    switch ($theme_name) {
     case 'advanced':
       $init['media_strict'] = array("false");      
       break;
    }
  }
  return $init;
}

Once that is added you may now embed SWF video in your nodes.