• I’m either going crazy or there is a bug in WP3.1 that is causing iframe code blocks to disappear from the visual editor window when I click on Update.

    My page has an iframe (youtube video) with additional text on the page. I placed the iframe code onto the page using the HTML editor. Later on in the day I needed to change some text on that page and used the visual editor to make the text changes but when I click Update, the iframe code disappeared.

    This has happened consistently since I first discovered this issue.

    Bug? Something I’m doing wrong?

Viewing 15 replies - 1 through 15 (of 21 total)
  • The Visual Editor will strip most (if not all) HTML markup from posts/pages. Solution: If you have added markup using the HTML tab, don’t switch to the Visual tab.

    It’s definitely not a bug, it is a feature – that is, what you are observing is the intended design.

    WordPress uses a custom configuration for TinyMCE (the Visual Editor), that excludes, among others, IFRAME from the list of valid HTML tags.

    You have two options:

    1) Filter the TinyMCE configuration to allow IFRAME tags
    2) As esmi said: for posts in which you need to add iframes, only use the HTML editor.

    Thread Starter cnymike

    (@cnymike)

    I realize that visual editors are not where iframe code should be placed. I always use HTML for that. But once a site is up and running, it’s not always obvious that a particular page has iframe code on it. If a user opens a page intending to edit the text on that page in the visual editor, not knowing that there is iframe code present, the user should not lose any iframe code that may have been on that page simply by opening it in the visual editor. That’s why it seems more like a bug rather than a feature. I don’t know anything about filters in TinyMCE, but apparently that is something I will have to learn because I manage a lot of WordPress sites and many of them have iframe code in them. I also realize that I can revert to a previously saved version of the page, in some cases, but that is not a solution but a safety cushion.

    Then you’ll want to filter the TinyMCE config.

    Add something like the following to your functions.php file:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Reference: https://tinymce.moxiecode.com/wiki.php/Configuration

    Thread Starter cnymike

    (@cnymike)

    Chip, your code was moderated. Could you try that again, using the pastebin?

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Um, hello. That code was not more than 10 lines. Come on.

    Just a second, cnymike. I’ll put that in a Pastebin. We’ve got some over-zealous moderators today, I guess. :/

    Thread Starter cnymike

    (@cnymike)

    Somebody needs to moderate the moderator I guess.

    Here you go: https://pastebin.com/rKuewx0P

    (And I took out the white space and the comments, just to ensure that it was, in fact, 10 lines exactly.)

    Thread Starter cnymike

    (@cnymike)

    Thank you Chip. I’ll see if that works for me. Now I gotta learn more about rutabaga’s.

    Thread Starter cnymike

    (@cnymike)

    Chip, sorry for the delay but your code worked perfectly. I’m now able to switch freely between HTML and visual editors without losing the iFrames code. Awesome and thanks again.

    Awesome! Glad you got it working!

    Thread Starter cnymike

    (@cnymike)

    Chip, I’m now having a related issue with quotes. What would I need to append to your previous code to also allow quotes not to get changed to curly quotes if I accidentally go into Visual editor mode?

    @cnymike, you need to remove the wptexturize() filter from the_content(). e.g. add the following the functions.php:

    remove_filter('the_content', 'wptexturize');

    Thread Starter cnymike

    (@cnymike)

    OK, I”ll give that a go. Thank you.

    And thank you for keeping that under 10 lines to escape the wrath of moderation :-0

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘WP3.1-iframe code disappears when editing page and clicking update’ is closed to new replies.