Some folks might have noticed my posting of a Youtube “video” (actually, it’s mostly an “audio”, but that’s being picky) here a couple of days ago.  The really observant probably noted that it didn’t work the first 68 times I tried to publish it.  I thought I’d share a little about what I discovered in that process. 

The normal “embed” code from Youtube itself doesn’t seem to work, at least not with IE7.  It looks like this:

<object width=”425″ height=”350″>
<param name=”movie” value=”http://www.youtube.com/v/Hjhi_FHxY8k”></param>
<param name=”wmode” value=”transparent”></param>
</object>

I did some poking around and found this thread of comments on the topic, which basically resolves that the underlying problem is that the Youtube embed code is improperly formed.  Within that thread is an alternate set of code that does work…it looks like this:

<object width=”425″ height=”350″ type=”application/x-shockwave-flash” data=”http://www.youtube.com/v/Hjhi_FHxY8k”><param name=”movie” value=”http://www.youtube.com/v/Hjhi_FHxY8k” /><param name=”wmode” value=”transparent” /></object>

Interestingly, it appears that WordPress likes to mess up the embed code even when it *is* correct.  I’d get it working, then edit the post and it would “break” the above code, removing some of the parameters.  Or at least that’s what it seemed to be doing. 

I finally got the post to work by turning off the rich editor in WordPress and using the second set of code above.  Hurray for persistance!

This Post Has 4 Comments

  1. Oblivions

    Interesting to note: I have problems with video from YouTube quality trying to embed in my blog. Sometimes it comes back with a comment that the HTML is not closed. I assume this is basic re-writing of the HTML to close it?

  2. Kelly Adams

    The problem in my instance (with WordPress) is, I believe, two-fold.

    First, WordPress itself tries to re-form HTML to “correct” errors: that messes up the poorly structured (but generally functional) default HTML provided by Youtube. It also can mess up some correctly formed HTML that WordPress doesn’t understand.

    Second, browsers that more strictly interpret HTML correctness (E.G.: IE 7) may reject incorrectly formed HTML even if I manage to get WordPress to stop messing with things.

    So, the answer (in my case) was to re-form the HTML into something that is correctly formed and to get get WordPress to stop “updating” the HTML by smacking it upside the head by disabling it’s rich editor. I don’t know what blog software you are using, Oblivions, but try my second example above and see if it works better.

  3. Oblivions

    Noted. I use Blogger Beta (well not Beta now) version. As you write the post in Blogger, there are two tabs on is to compose as per usual and the other is the same but show the HTML. The biggest error I get is with embedded links in code to copy and past (not just YouTube actually).

    It always seems to come back that the code for the link (which it highlights nicely so I don’t have to go looking for the error it perceives) and says the the tag is not closed. Perhaps that’s all I need do is add the closing tag. Sometimes that works sometimes… not so much. Probably because my ability to a) read code is poor and thus b)knowing what tag to use is vague.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.