YouTube embed code

Embedding YouTube videos in blogger has always been a hit and miss affair for me. Sometimes it works and sometimes it doesn't, all I know it has something to do with the xHTML code generated from YouTube's post feature, which apparently has some error when you try to post it on Blogger.

So most of the time, I'll try to post videos from YouTube with minimal edits, meaning very little text, no formatting, links or even images. I've managed to do a few posts previously with formatting and stuff but it was just too tedious; I even had to redo the post a few times.

I had this problem again when I tried to post John's video, so I decided to google it up on the Internet, and voila I've found a solution, thanks to Psy2k's simple tutorials. It's really trivial, and I'll have to blame my mediocre HTML knowledge for not realizing this earlier.

This is taken directly from Psy2k's post

Validate the Youtube embed code!
As we now the embed code of youtube is a mess as it uses the embed tag which does not validate as xhtml. Using the code this tip you can embed a youtube or google video to your site or blog and keep your code validated:

<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/moviecode" width="400" height="326"><param name="movie" value="http://www.youtube.com/v/moviecode" /></object>

The moviecode is a code found in each youtube video address and is after v= until the first ampersand (&).

For example in this YouTube URL...
http://www.youtube.com/watch?v=xmHHjUZPyMY

The moviecode is xmHHjUZPyMY. All you need to do is paste the code in to your blog editor and replace the moviecode portion with an actual YouTube moviecode.


Posting YouTube videos on the blog has just become so much easier for me.

Comments