1

Which filter if removed allows iframes to be inserted into wordpress posts?

3

This filter does not. This feature is disabled in the visual editor TinyMCE.

function wpse49619_change_mce_options($initArray) {
    $ext = 'iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]';
    if ( isset( $initArray['extended_valid_elements'] ) ) {
        $initArray['extended_valid_elements'] .= ',' . $ext;
    } else {
        $initArray['extended_valid_elements'] = $ext;
    }
    // maybe; set tiny paramter verify_html
    //$initArray['verify_html'] = false;
    return $initArray;
}
add_filter('tiny_mce_before_init', 'wpse49619_change_mce_options');

Also you can use examples from WPEngineer how to enhancement TinyMCE.

| improve this answer | |
  • Please put relevant code in your answer rather than merely linking to an external site. This one should be straight-forward enough that the code shouldn't be too onerous. :) – Chip Bennett Apr 20 '12 at 1:31
  • 1
    Ok @Chip Bennett, I added little code :) – user15194 Apr 20 '12 at 1:50
  • Thanks! Now, I can put iframe directly into the editor BUT I used media_send_to_editor($html) to add iframe to editor but 'Add Media' screen hangs up. What could be the problem? – a_fan Apr 21 '12 at 7:22
  • Ok I found the problem. This happens when Visual (WYSIWYG) is active. Works fine when HTML view is active. – a_fan Apr 21 '12 at 7:54
  • Well this is because I was getting <iframe ... /> from the Video API I am using. This causes Cannot call method 'indexOf' of undefined in wp-tinymce.php. Should be <iframe ...></iframe>. HTML view auto converts this. WYSIWYG does not! – a_fan Apr 21 '12 at 9:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.