Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer

up vote 2 down vote accepted

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.

share|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 :) – wikicms 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? – afnrf 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. – afnrf 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! – afnrf Apr 21 '12 at 9:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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