WordPress and iFrames

iFrames are coming!  As you may have already noticed, your favorite video sharing websites like Vimeo & YouTube had begun introducing iFrame based syndication of their embeddable players.  While this offers a variety of new features, like iPad support for embedded videos, it might be very challenging for WordPress bloggers to insert iFrame-based code into their blog posts.  By default, such code would be filtered out by TinyMCE – WordPress’ WYSIWYG (or Rich Text) editor.

Fear not, the solution is simple enough.  Just add the following code to the functions.php file of your template, and voilà – life is beautiful once more.


function add_iframe($initArray) {
$initArray['extended_valid_elements'] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]";
return $initArray;
}
add_filter('tiny_mce_before_init', 'add_iframe');