Support » Fixing WordPress » WP3.1-iframe code disappears when editing page and clicking update

  • 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)
  • esmi

    (@esmi)

    Forum Moderator

    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.

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

    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.

    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.

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

    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: http://tinymce.moxiecode.com/wiki.php/Configuration

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

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

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

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

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

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

    Somebody needs to moderate the moderator I guess.

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

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

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

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

    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.

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

    Awesome! Glad you got it working!

    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?

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

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

    remove_filter('the_content', 'wptexturize');

    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.