WordPress.org

Ready to get started?Download WordPress

Forums

Google Maps (iframe) deleted with TinyMCE and Advanced TinyMCE (6 posts)

  1. gagnonconsulting
    Member
    Posted 5 years ago #

    When I enter the Google code for a map (which uses iframe) in the HTML editor, everything is OK and the map appears in my post. But if I switch the editor to Visual mode, the iframe code is stripped out. I have tried using the Advanced TinyMCE editor with the same issue. Is there any way to tell the editor not to strip this code?

  2. smilinghuman
    Member
    Posted 5 years ago #

    I was having the same exact problem and then I found the following post: http://wordpress.org/support/topic/156276.
    Scroll down to the reply by vizthink and you will see a solution. I also installed the Advanced editor and this solution did not work for me until I uninstalled it. Once I removed the editor, all was good. Now maybe you could look into the editor and find a similar location to change. I did not really need the advanced features, so I just uninstalled it.

    Pertinent details from that reply with the implied "at your own risk"

    1. Locate the file 'tiny_mce_config.php' ( it should live in %your_blog_root%/wp-includes/js/tinymce/ )
    2. Assuming you want to avoid catastrophe if things go awry, back this file up!
    3. Open this file in any text editor and locate the following code ( Line 298 for me )
      // Add external plugins and init
      $content .= $ext_plugins . 'tinyMCE.init({' . $mce_options . '});';
    4. Replace with this ( or a variation to suit your own needs )
      // Add external plugins and init
      $content .= $ext_plugins . 'tinyMCE.init({extended_valid_elements : "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]",' . $mce_options . '});';
    5. Save the file back to its original location
    6. Clear your browser cache ( for good measure )
    7. While technically unnecessary, you can also delete or rename the folder 'js_cache' ( it should live in %your_blog_root%/wp-content/uploads/ )
    8. Test your new settings with the desired code by toggling back and forth between the 'Visual' and 'HTML' tabs at least once. Return back to the HTML view to verify the code is still there and finally back to the 'Visual' tab to save/publish a test post.
  3. shacker
    Member
    Posted 5 years ago #

    Question: Since it's possible to solve this same problem by disabling the Visual Editor, it's clear that WordPress itself does not consider iframe a security issue. And since it's possible to make this change to tinymce without breaking things, it's clear that iframe isn't a problem in general for tinymce. So why in the world is iframe disabled by default, but only at the tinymce layer?

    For those of us managing large WP installation bases through a checkout system, hacking core is NOT a viable solution. But this iframe problem has vexed WordPress forever. What's the story?

    Thanks for the tip.
    ./s

  4. shacker
    Member
    Posted 5 years ago #

    I think I've gotten to the bottom of how and where iframe is disabled in WP, and have written a tutorial for journalists explaining what needs to change to have relatively easy Google Map publishing capabilities:

    Using Google Maps in WordPress

  5. shonkyboy
    Member
    Posted 4 years ago #

    Hi - i cannot find the file 'tiny_mce_config.php' in the directory - any ideas?

  6. eswhite
    Member
    Posted 4 years ago #

    I was able to fix this (using TinyMCE Advanced too) by adding the following line to my functions.php file:

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

    Thanks to the suggestion above by @smilinghuman and this Nabble thread

Topic Closed

This topic has been closed to new replies.

About this Topic