PHPology.co.uk Collective of freelance web developers and designers

  • Wordpress editor removing iframe tag between visual and html mode

     Supporting a Wordpress website for a client and came across an issue where when they were adding in <iframe> tag into the WYSIWYG and switching from html to visual - visual to html, the code would disappear.

    Problem was solved by adding this code to functions.php

    function mytheme_tinymce_config( $init )

    {

    $valid_iframe = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]';

    if ( isset( $init['extended_valid_elements'])){

    $init['extended_valid_elements'] .= ',' . $valid_iframe;

    } else {

    $init['extended_valid_elements'] = $valid_iframe;

    }

    return $init;

    }

    add_filter('tiny_mce_before_init', 'mytheme_tinymce_config');

  • Comments

    0 comment(s)

    Be the first to comment!

    Add your comment
    Name*:
    Email*:
    Website URL (including full path e.g. http://www.yourwebsite.com/):
    Comment* (html/script tags will be removed):
    What do you see below?: