WordPress YouTube Widget

Number 7 in Widget-A-Day is a YouTube widget.

It'll display a YouTube video in the sidebar. Just enter the URL of the video, and it'll show in the sidebar. You can change the width and height, and make it autoplay or not.

Download youtube.zip

SVN Checkout
svn co http://svn.wp-plugins.org/youtube-widget/trunk

Default display:
youtbe1cropped.png

Admin panel:
youtube2cropped.png

Requirements

Installation

  1. Download youtube.zip
  2. Extract and upload youtube.php to the plugins/ directory
  3. Enable YouTube Widget in the Plugin admin panel
  4. In widget admin panel, place YouTube in the sidebar, and edit it to enter the YouTube URL, not the embed code

Download youtube.zip

86 Comments

  1. Nenad says:

    Hi.
    Thanks for this great plugin.
    I am interested should I be able to put more than one widget in sidebar?
    Thx.

  2. James Wilson says:

    Other than Text and RSS widgets, I don't think you can have multiple widgets of the same type at once.

  3. Chellz says:

    Great plugin thx!!

  4. melanie west says:

    i just installed this in my blog with zero problems, love it! now i should probably started posting more on youtube instead of daily motion. thanks for a really great great plugin!

  5. it doesn't works on Internet Explorer

  6. James Wilson says:

    Hmm, it seems it doesn't, but regular embeds straight from Youtube also aren't working for me in IE6. I think it might be a Youtube problem.

  7. Carl says:

    Great plugin, works fine in Firefox, Camino and Safari.

    I would love to see capability to have multiple instances of the widget. A few other plugins other than the standard Text and RSS do it.

    Thanks for making this.

  8. James Wilson says:

    Thanks, it also works in Konqueror and Opera.

    But it does seem to be possible to do to multiple instances. I searched for it before, and never found anything, but there are some. I'll try to hack a version together.

  9. Robert says:

    Hi,

    This looks like a great widget. Unfortunately, I can't use widgets in my sidebars, as I've already got them set up with various plugins, etc. Therefore, I was wondering if I could just use it as a plugin; that is, paste some code into my sidebar rather than using the widget panel.

    Thanks again

  10. James Wilson says:

    So something like youtube(url,[width,height]) which would show the video?

  11. [...] is a plugin based on the YouTube widget. It'll display a YouTube video, most likely in your sidebar, by calling the youtube function [...]

  12. AleGT says:

    I change the YOUTUBE URL in your plug-in but it not show the video in sidebar…. Can you help me?

  13. AleGT says:

    Your plug-in dont work with BR.YOUTUBE or UK.YOUTUBE…

  14. James Wilson says:

    Yup, probably because I've never used them.

    Replacing:

    $videoid = str_replace( array("http://www.youtube.com/watch?v=", "http:/youtube.com/watch?v="), "", $options['video']);

    With:

    $videoid = str_replace( 
    				array(
    					"http://www.youtube.com/watch?v=", 
    					"http:/youtube.com/watch?v=",
    					"http://br.youtube.com/watch?v=",
    					"http://uk.youtube.com/watch?v=",
    					"http://fr.youtube.com/watch?v=",
    					"http://ie.youtube.com/watch?v=",
    					"http://it.youtube.com/watch?v=",
    					"http://jp.youtube.com/watch?v=",
    					"http://nl.youtube.com/watch?v=",
    					"http://pl.youtube.com/watch?v=",
    					"http://es.youtube.com/watch?v="
    				), 
    				"", 
    				$options['video']
    			);

    Should do the trick.

    Note: I should just do a reg-ex, but I tried doing it quickly and it didn't work right in the 2 minutes I worked with it, so I said screw it. I'll have a reg-ex one real soon now.

  15. David says:

    Hi,

    Is this incompatible with WP 2.0.4? Or is there a minimum size for the youtube videos (my sidebar requires things to be 160 px wide or less)?

    It's not working for me. And I wish it would!

  16. James Wilson says:

    It should work. It requires the Wordpress widgets plugin and a widget compatible theme, but other than that, it's fairly simple.

  17. Trey C. says:

    The plugin installed perfectly. However,I noticed that after trying to change to a new youtube video, it didn't work. I took a look at source code and for some reason it tries loading the URL in the same string instead of just taking the video id….

    If this happens to you just copy the video id which is everything after the "V="

    http://youtube.com/watch?v=WsvoC1vwTYA

  18. James Wilson says:

    The removing of the YouTube URL is quite dumb. It should be a reg-ex, but I got lazy. If anything is slightly different with the URL, even case wise, it won't work right.

  19. tom says:

    Hey,

    How do you get into that admin panel to change the size/youtube url?

    Tom

  20. James Wilson says:

    @tom, you click the box on the right of the thing that you drag to add the widget. It's a box with lines on it. Just click it and the admin panel will pop up.

  21. pebarco says:

    Hey, this plugin is so cool, thanks dude.

  22. Dan says:

    great widget, thanks a heap.

  23. [...] Nothing to see here… » WordPress YouTube Widget (tags: video wordpressplugin wordpresswidget) [...]

  24. Orlando says:

    hi!
    i can't drag & drop my wigets on the sidebar..
    Pleas, Can you give me the php code to insert manually the widget in my sidebar.php and the parameters tha i have to change in the youtube.php?

    thanks a lot!

  25. James says:

    If you just want to manually add the video to your sidebar, use the YouTube sidebar plugin instead of the widget.

  26. derrick says:

    thanks. great widget. One thing I'd like to see is an option to have it on the main page or subpages online. NextGen widgets have that feature. I'd like to have video on the main page, but not on the subpages.

    Anyway, great widget. simple, clean. very cool.

  27. James says:

    I'm not sure if you can do that with the Wordpress widgets plugin, but I can see, I guess.

  28. derrick says:

    I've been talking to someone at WP board about it too http://wordpress.org/support/topic/143753?replies=5

    He thinks he has the code, just trying to figure out where it fits. . .

  29. [...] where I could play/list YouTube videos, in the same kind of style as the flickr widget. I found this one by James Wilson, which appears to be very simple in terms of what it does, yet effective in how it [...]

  30. blamsa says:

    In wordpress 2.5 is not working. Any idea??

  31. Dylan says:

    I install the youtube.php and when I go to activate it this error comes up every time:

    Warning: Cannot modify header information – headers already sent by (output started at /home/scoopgro/public_html/dblog/wp-content/plugins/collapsing-categories/collapsCatList.php:200) in /home/scoopgro/public_html/dblog/wp-login.php on line 202

    Warning: Cannot modify header information – headers already sent by (output started at /home/scoopgro/public_html/dblog/wp-content/plugins/collapsing-categories/collapsCatList.php:200) in /home/scoopgro/public_html/dblog/wp-login.php on line 214

    Warning: Cannot modify header information – headers already sent by (output started at /home/scoopgro/public_html/dblog/wp-content/plugins/collapsing-categories/collapsCatList.php:200) in /home/scoopgro/public_html/dblog/wp-includes/pluggable.php on line 689

    I don't know what is happening. This also happens when I try to log in.

  32. Dylan says:

    Never mind, it was a different widget. This one works great!

  33. Dingus says:

    Fatal error: Call to undefined function: str_ireplace() in /home/XXX/public_html/wp-content/plugins/youtube-widget/youtube.php on line 110

    Any ideas why this might be happening?

    I was unable to clearly add it to my sidebar widget, am I doing something wrong?

  34. James says:

    I would guess str_ireplace doesn't exist in your environment. You're probably running PHP 4, which it apparently isn't in, and I didn't know when I changed it to this. You can try changing it to just str_replace, and it should work. I'll update it to fall back to str_replace when str_ireplace doesn't exist.

  35. [...] As instruções de instalação,  e o sítio de download, estão aqui. [...]

  36. mee says:

    Hi
    ThanX for the cool idea. But it doesen't work anymore with WP 2.5.1. I got an erroro …

  37. DJ says:

    How do i set this up so that i can enable this widget more than one time on a page?

  38. mee says:

    I diden't done any extra. I just got WP 2.5.1 installed and draged the the youtube widget v 1.1 into the others and when I want o save that in the widgets I got an error:

    Fatal error: Call to undefined function: str_ireplace() in /home/.cacaodryer/oweibel/wasabi.li/wp-content/plugins/youtube.php on line 110

    And after that the youtube widget is deleted from the list …

  39. Tanya says:

    Hi, I like the plugin very much but I have the following problem: after I first have installed it, it worked without any problems. Yesterday I decided to change the title form My video to a title in Bulgarian /written with cyrilic letters/ and the video disappeared. I deleted the title and returned it to My video, but the plugin doesn't work anymore like it used to.

    What did I do wrong and what should I do to correct it because I want my video plugin to work in the sidebar.
    Thanks

  40. Lawrence Ip says:

    I would like to thank you for writing this plugin.It works just perfectly on 2.5.1 for me, I am using the Insense Theme by Design Disease. Yup… the plugin works! I am not a WordPress geek, but I do know that minimum server requirements for a lot of plugins require php 5 these days (at least to get the "best" functionality out of them).As far as themes are concerned.. well issues can arise out of there too. So as far as plugin development goes, the authors of the script can no way give end users absolute assurance to the tune of compatibility and do us a great service. Thanks Again.

  41. john says:

    Works great when I copied everything after the v=. Had trouble before that. Great plugin…thanks!

  42. Jamie says:

    Lovin' this widget! Just have one question. On your example of how the youtube player will look, your play bar is all nice, small and red. When I install my youtube widget the play bar is big, ugly and … gray. What could cause the difference in appearance for this? Would it have anything to do with the style one is using for their site (.css) I'd reeeally like to have my play button, progress bar, volumn, etc. look nice a tiny like yours. I'm having to size my video down quite a bit since my sidebar is not terribly wide, so having a huge, gray play bar looks pretty nasty. THANKS for creating this youtube widget! It's still my favorite one that I have tried!!

  43. Lance says:

    Hi, was just wondering how I could call this block manually? I want it to appear as part of my header instead of in the sidebar. Is it possible?

  44. James says:

    @Jamie, If YouTube updated their embed player kidna recently, that could be it

    @Lance, here

  45. dan says:

    Just wanted to tip off anyone looking here with the "call to function" error- search for "str_ireplace" and change it to just "str_replace" (without the "i") and it should work again.

    –d

  46. Does not work in 2.6.2, any idea why?

Leave a Reply