<nerdy optional=completely> In the public interest (and so I can find it later), I thought I'd reveal how I embed YouTube videos. YouTube makes this really easy, and they take you almost all the way there, but not quite quite. If you view a video on the YouTube site, you'll notice at the upper right they have an Embed text box with the HTML you have to insert in a page to play that video. You can configure the size, whether to include a border, the color, and so on... really nice. But just sticking this HTML into your page this isn't exactly what you want, because what you really want is to display an image first which, when clicked, causes the YouTube video to play. This is prettier for people who visit the page itself, and much prettier for people who read the page via RSS readers and so on which may not know what to do with embedded videos. Okay, so how is this done? Well first make the image; generally edited from a screenshot of the YouTube video, but it can be any image at all. And then insert the following HTML into the page:
The numbers are so I can refer to the lines. The brown text is what you get from YouTube's Embed text string. You start by copying that in, and then add the rest. Some notes:
One more note: for more than one of these on a page, use unique id= values for the <img> and <div> tags, and modify the onlick= JavaScript accordingly... </nerdy> |
|