Sailing the seas of online marketing and plundering the riches as an affiliate pirate.

Friday, February 4, 2011

Wordpress Strips New YouTube iframe Embed Code

I frequently use Youtube videos on my Wordpress-based gaming blog to show off new game trailers. Youtube recently introduced a new kind of embed code which uses iframe HTML element rather than object element as before. This causes some problems with Wordpress editor, since apparently it strips iframe tags from the post.

You can, of course, simply use the old code that uses the object element, but we can't be sure Youtube will keep supporting the old embed code forever. Also, the new code provides support for HTML5 videos.

There is an easy workaround to make iframe work in Wordpress post editor:

1. Use HTML mode when editing posts. Paste in the new Youtube iframe embed code and publish the post while still in HTML editing mode. Do NOT switch to Visual mode, as this will cause all iframe tags to disappear!

2. Use a Wordpress plugin that prevents it from stripping iframe elements. Frankly, I prefer using as little plugins as possible to keep the installation uncluttered and reduce CPU and RAM usage on my shared hosting account. However, if you want to keep using the Visual mode and keep Youtube iframes from disappearing, then using a plugin is a valid choice.

Which plugin to use? I know at least two that do the job:
  • IFRAME Embed For YouTube adds a quicktag to the Wordpress Post Editor - you simply post the Youtube video URL into this additional tag, and when the post is published the iframe embed code will be displayed correctly.
  • TSL iframe unfilter is a much more simple plugin that simply prevents Wordpress from stripping any iframe tags in the post editor.

Now you know how to use the new Youtube iframe embed code on Wordpress without problems. I am sure the future versions of Wordpress will fix this little inconvenience so you'll be able to embed Youtube videos without the need for any plugins or additional hassle.


Marco said...

Thanks for sharing, it worked perfectly!

Anonymous said...


Anonymous said...

Actually, if you check "When possible, embed the media content from a URL directly onto the page. For example: links to Flickr and YouTube" setting in Media, Wordpress will automatically embed videos that you enter as simple URL (like No need to paste in embed code!

But it does use the old code with "object" tag and not the new code with "iframe" tag.

Post a Comment