Title: Stripping Youtube Code
Last modified: August 19, 2016

---

# Stripping Youtube Code

 *  [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/)
 * Howdy… it seems that wordpress sometimes strips video embed and iframe code from
   posts while I’m composing them. It doesn’t happen all the time… I think it only
   happens if I “preview” then come back to edit. It may be related to the author’s
   level of privileges since I haven’t seen it when logged in as admin. Is this 
   a known bug?

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/stripping-youtube-code/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/stripping-youtube-code/page/2/?output_format=md)

 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920048)
 * This is not a bug, it’s actually a feature. The visual editor is configured to
   strip javascript, embed code, invalid HTML, etc. It is slightly less strict for
   admins (or any users with the unfiltered_html capability) than for authors.
 * However, ideally, you should use the oEmbed interface to embed YouTube videos
   instead of using YouTube’s crummy embed code. To use oEmbed, you simply need 
   to make sure the Settings -> Media -> Auto-Embed option is checked in your administration
   area, then simply insert the URL of the YouTube video.
 *  Thread Starter [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920212)
 * Interesting…. it seems to happen even if I’m using the HTML mode, however. I’ll
   try that auto embed thing.
 * Wow… it actually works. I’m impressed! Thanks!
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920219)
 * If I may chime in here – Curtiss, do you or does anyone know if there’s a way
   to get oEmbed to use YouTube’s (and other video sites’) iframe embed code, instead
   of the object/embed Flash method, which won’t be viewable on iPads/iPhones? I’ve
   been looking for the best way to do this and tried a few iframe plug-ins today,
   with not great results. Thanks for any suggestions.
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920221)
 * Just discovered a thread with some iframe shortcode solutions that look promising:
 * [http://wordpress.org/support/topic/new-youtube-embed-code-disappearing?replies=7](http://wordpress.org/support/topic/new-youtube-embed-code-disappearing?replies=7)
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920224)
 * I was under the impression that the default implementation of YouTube’s oEmbed
   code uses the iFrame now, instead of the embed code. Is it not doing so on your
   website?
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920232)
 * Curtiss – correct, I tried the oEmbed method with a YouTube link and it did **
   not** use iframe code, it used the object/embed code. v. 3.0.5.
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920234)
 * I just checked online, and it looks like YouTube has not yet made that the default
   standard.
 * However, you can retrieve iFrame oEmbed code by appending `&iframe=1` to the 
   end of the oEmbed URL.
 * In order to do that, you probably need to hook into whatever WordPress filter
   is available when the URI is built, but I’m not sure exactly which filter that
   is right now. I found the oembed_dataparse filter, but that is run after the 
   oEmbed request has already been made, so we’d have to find a filter that runs
   before that.
 * If I get a chance, and noone else answers the question, I’ll try to take a look
   at the source code later to see if I can find the right filter.
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920235)
 * Thanks so much, Curtiss! I just tested oEmbed again, adding the `&iframe=1` query
   string and it still used the object/embed code, so you’re right – looks like 
   something extra needs to be added. Will be very interested to see if this is 
   possible.
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920274)
 * I looked through the source code and couldn’t really find any good filters to
   hook onto, unfortunately.
 * However, I did find two plugins in the repository that look like they might be
   helpful. I haven’t used or tested either of them, but they both look promising.
    - [Smart YouTube](http://wordpress.org/extend/plugins/smart-youtube/)
    - [IFRAME Embed For YouTube](http://wordpress.org/extend/plugins/iframe-embed-for-youtube/)
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920275)
 * Thanks so much for having a look, Curtiss, I really appreciate it.
 * I have tried some YouTube-specific plug-ins and some of them work OK, but I’m
   hoping to find a solution that will work across all platforms – i.e. to allow
   Vimeo’s iframes, etc. I was planning on testing this one on Monday:
 * [TSL iframe unfilter](http://wordpress.org/extend/plugins/tsl-iframe-unfilter/)
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920281)
 * Sorry I couldn’t help more.
 * FYI, though, the Vimeo oEmbed feature does use iFrame as default, so you don’t
   need any changes at all to use iFrames with Vimeo.
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920286)
 * > the Vimeo oEmbed feature does use iFrame as default, so you don’t need any 
   > changes at all to use iFrames with Vimeo.
 * Great to know – thanks so much!
 *  Thread Starter [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920357)
 * Hey… so I just had a Vimeo video disappear when I edited a post. How am I supposed
   to embed it? Is there a URL method?
 * In all honest, this is still a bit of a bug. What if I wanted to put a normal
   iframe into a post? Just for the hell of it? WP shouldn’t be stripping this stuff!
 *  [Ashish Kumar (Ashfame)](https://wordpress.org/support/users/ashfame/)
 * (@ashfame)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920358)
 * Hi Nick,
 * You can use it like this ‘[embed width="650"]http://vimeo.com/20797313[/embed]‘
 * Semantically putting iframe in a post is not correct so it is like that with 
   WordPress but with shortcodes, one can do anything they want within the post.
 *  Thread Starter [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/stripping-youtube-code/#post-1920365)
 * Okay… this is still a bit of a problem because many people will continue to try
   and use embed codes, or iframes, and then freak out when they disappear. It’s
   kinda cool that just throwing a URL in there works, but educating people over
   and over about it gets incredibly tedious.
 * Plus, by taking away my power as a publisher to control this stuff, all kinds
   of annoying problems happen. For example, what if I want to adjust the size of
   the video? Or center it? With real code I could do that.

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/stripping-youtube-code/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/stripping-youtube-code/page/2/?output_format=md)

The topic ‘Stripping Youtube Code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 22 replies
 * 5 participants
 * Last reply from: [nickaster](https://wordpress.org/support/users/nickaster/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/stripping-youtube-code/page/2/#post-1920388)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
