Drupal – Add iframe in TinyMCE Editor

If you have installed the WYSIWYG module with TinyMCE Editor, you will find that it does not support the iframe element. Say if you embed a Google Map in the HTML body, it will disappear once you edit the node.

Ya, it’s Google again, i found a post written by Sam Michel who resolve the problem just by simply create a custom module with the hook_wysiwyg_plugin.

function <module>_wysiwyg_plugin($editor, $version) {
  switch($editor) {
    case 'tinymce':
      return array(
        'iframe' => array(
          'extensions' => array('iframe' => t('Iframe Fix')),
          'extended_valid_elements' => array('iframe[src|width|height|frameborder|scrolling]'),
          'load' => FALSE,
          'internal' => TRUE,
        ),
      );
  }
}

 

Now, go to Adminster -> Site configuration -> Wysiwyg profiles and edit the TinyMCE editor. Select the iframe fix at the bottom as follow.

 

The iframe should work now. Thanks Sam.

Done =)

Reference: toodlepip – Using Iframes With Drupal’s WYSIWYG Module And TinyMCE

2 thoughts on “Drupal – Add iframe in TinyMCE Editor”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.