Jump to Content
  • Journal
  • Portfolio
  • Projects
  • About
  • Contact

Placing YouTube videos in your blog with KFE

25 Feb 07

One of the most common questions I get about using Kimili Flash Embed is how to go about posting YouTube videos on a site with it. As you’ll see, it turns out to be a relatively simple and painless process.

YouTube’s Embed Code

As you probably already know, YouTube provides “Embed” code for just about every video on its site. It’s meant as an easy way to copy and paste the code to place a video onto your site / MySpace page, or whatever. It looks something like this:

  1. <object width="425" height="350">
  2. <param name="movie" value="http://www.youtube.com/v/crfrKqFp0Zg"></param>
  3. <param name="wmode" value="transparent"></param>
  4. <embed src="http://www.youtube.com/v/crfrKqFp0Zg" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>
  5. </object>

There are a couple of reasons why copying and pasting the above HTML code is not exactly ideal. If you’re using the rich text editor to write your posts in Wordpress, for instance, it will treat the code as regular text, converting the brackets to character entities and will end up just displaying the code in your post for all to read. Not exactly what we wanted. Another reason that isn’t the ideal approach is that it doesn’t easily allow for alternate content such as an image or text stating that a user needs the Flash Player to watch the video. Besides, YouTube itself uses the SWFObject code – the same code that KFE is based on and utilizes – to post videos on its own site. If it’s good enough for them, it’ll work great for you.

KFE has 3 required attributes – movie, height and width. Remember that movie is the URL to the SWF file that we want to display. If we dissect the YouTube embed code, we find that we only need the first two lines in order to get all the information we need to create a valid KFE tag. Take a look:

  1. <object width="425" height="350">
  2. <param name="movie" value="http://www.youtube.com/v/crfrKqFp0Zg"></param>

Using that, I can just copy the three values to create my KFE tag. If you’re using Wordpress, it looks like this:

  1. [kml_flashembed movie="http://www.youtube.com/v/crfrKqFp0Zg" height="350" width="425" /]

For Textpattern users, it’s much the same:

  1. <txp:kml_flashembed movie="http://www.youtube.com/v/crfrKqFp0Zg" height="350" width="425" />

You can, of course adjust the height and width to fit the layout of your site if desired, or you can simply leave it as is.

Voilá  – that’s all there is to it. Nothing else is required or necessary.

Comments

Pamela says:
628 days ago ∞

Thanks for the information. I really help a dummbies for codes like me.

Bert (Stickske) says:
539 days ago ∞

Thanks, the information was usefull for me.

Marios says:
533 days ago ∞

Yeah, I’m glad I just found it.
I’ll let you know if trouble is at hand.

JFYI: By combining Pipes and Grazr, you can now also generate RSS Feeds in your custom Widgets. ( Just have to make the code more compliant )

Check it out here:
AlistAport

It is just not so Userfriendly. (fiddle around with the widget menu a bit)
Lets you play also the Videos right from within the widget.

Now, whenever I go to Youtube, those Playlist Feeds get updated automatically (RSS and OPML)

regards

Arjan says:
523 days ago ∞

Thanx for the info!! This is real easy

flv downloader says:
518 days ago ∞

Great tutorial! Thanks for sharing.

Deb Armp;d says:
442 days ago ∞

How would you put alt text into the above code?

Michael Bester says:
442 days ago ∞

Why not try the alttext attribute?

Deb Armp;d says:
441 days ago ∞

Where within the code does it get placed? I have tried several spots and it never shows?????

Michael Bester says:
441 days ago ∞

If you see the Flash, it doesn’t show. That’s why it’s alternative text. It’s for people who don’t have Flash installed.

Deb Armp;d says:
440 days ago ∞

So if I can’t see it but still wait to include it —- where should it go??????

Deb Armp;d says:
440 days ago ∞

I’m taking a class and we are required to enter the alt so I have disabled FLASH but can’t get the alt to display???

Michael Bester says:
440 days ago ∞

It’s an attribute that gets added to the tag like any other KFE attribute. Try this:

[kml_flashembed movie="http://www.youtube.com/v/crfrKqFp0Zg" height="350" width="425" alttext="This is your non flash content" /]

James says:
402 days ago ∞

Hi Michael,

I hate to add to what shouldn’t be an ongoing issue considering the simplicity of your instructions, but I’m having trouble embedding youtube files via your plugin.

I’ve tested embeddable urls from other streaming sites (imeem, animoto, google video, etc.) and I’ve also embedded swfs from my server directly, but for some reason the YouTube urls are not loading. An instance of the flash player loads but not the movie.

You mentioned that youtube is using the swfobject. Is it possible that they are using a later version of swfobject which may be causing a conflict with your plugin?

I’m using wp 2.5.1 hosted on mediatemple grid servers and the latest version of your plugin with just the default wp plugins.

Michael Bester says:
401 days ago ∞

@James – I saw your email. Please re-read the article above. When you define the movie parameter in your KFE tag, make sure you’re using the URL that YouTube generates in its video embed code, not the URL from the browser address bar. That’s not going to work for you.

trevor says:
194 days ago ∞

I’m not sure whether it’s because I’m using kimili 2.0 in its beta phase, but I’m finding that when i use the method described above, it works as it’s supposed to, TWICE. I end up with a floating video around my screen. Help!

trevor says:
194 days ago ∞

I just overcame this by inserting wordpress’ “MORE” tag just before the video.

thanks

Your Turn





Flickr

  • Practice, Practice, Practice
  • Practice, Practice, Practice
  • Rose Star
  • Ostrich
  • What Are You Looking At?
  • Mandrill
  • Peace Poll

See more at Flickr

Recent Listening

  1. Robert Johnson: The Complete Recordings
  2. Tom Waits: Real Gone
  3. Charlie Parker - Bird's Best Bop on Verve
  4. Charlie Parker - Best of The Complete Savoy & Dial Studio Recordings
  5. The Beatles - Abbey Road
  6. Sérgio & Odair Assad – Latin American Music For Two Guitars
  7. Björk - Medúlla
  8. Erykah Badu - Baduizm
  9. Ali Farka Touré: Savane

See more at Last.fm

Tweet, Tweet

  • I SOOOO need to get myself an office. #workingFromHomeIsFun 2 days ago
  • Sweet typographic design: <a href=“http://finaleyes.org.

    Reminds”>http://finaleyes.org.

    Reminds me of my site, http://kimili.com, but better. (via @meaganfisher via @weightshift)
    3 days ago
  • That last thunderbolt rocked the house! Must’ve been right around the corner. 3 days ago
  • @arockalypse I’m jealous. La Dolce Vita, indeed. 3 days ago
  • Gotta keep practicing. http://www.flickr.com/photos/m… 5 days ago

See more at Twitter

©MMII – MMVIX Michael Bester