Adding Flash Embed support in TinyMCE Editor

By Akbar 1 min read 17 comments

Today when working on a project, which uses the TinyMCE editor to HTML editing, I needed to add support for Flash embedding. When I tried to add the OBJECT or EMBED tags in the HTML source window, these were auto removed by the TinyMCE. Hmm… ‘there must be a simple of doing it’, I thought. Sure enough, I searched the web and there was an easy way to achieve the goal. So, all you need to do is just set the “extended_valid_elements” attribute with correct tags.
Here is how I did that:

tinyMCE.init({
    mode : “textareas”,
    editor_selector:
“mceEditor”,
    theme :
“advanced”,
    theme_advanced_buttons1 :
“bold,italic,underline,strikethrough,|,forecolor,backcolor,|,link,unlink,image,code”,
    theme_advanced_buttons2 :
“”,theme_advanced_buttons3 : “”,theme_advanced_buttons4 : “”,
    theme_advanced_resizing :
true, tab_focus : “:prev,:next”,
    extended_valid_elements :
“object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode]”
});

Job done. You can now insert the FLASH stuff like movies from youtube.com easily on your site.

Feedback & Comments

17 Responses

  1. Hi,
    you need to include “media” plugin and then set “media_strict” to false.

    Regards
    Anu

  2. it doesn’t work (with the last version). sorry..

  3. Thanks for this post. I use drupal and this helped me with a patch posted here:

    http://drupal.org/node/325491

    For those above where this doesn’t work – it seems there are several versions of html that you can use to embed youtube videos, so check what you’re using, you may need to add some other attributes to allow. I needed to allow ‘data’ and ‘type’ for the object tag.

  4. syedgakbar

    Hmm… Strange. Try doing thes:

    1. First try to move the extended_valid_elements, after the valid_elements in the initialization.

    2. Second try to remove the valid_elements elements al-together.

    3. Use the initialization code which I posted in the first message.

    See if any of these works.

    Regards,
    Akbar

  5. Thanks.
    It’s strange, but it seems to work when I remove valid_elements and extended_valid_elements from init altogether.

  6. syedgakbar

    Yigi,

    I have checked this and it looks good to me. The only thing you might want to verify check is that sometime it might take long (around 5-10 seconds) before the actual YouTube video appears. I am not sure, why there is such random delay sometime.

    See if this is the issue with you? Another thing you can do is that once you have saved the HTML, try to reload the HTML and copy and paste it into another simpel HTML file. See if that works?

    Regards,
    Akbar

Leave a Reply