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

96 Comments

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

  2. 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!

  3. 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.

  4. 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.

  5. 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

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

  7. 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.

  8. 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!

  9. 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

  10. 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.

  11. @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.

  12. 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!

  13. 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.

  14. 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.

  15. 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?

  16. 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.

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

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

  19. 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 …

  20. 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

  21. 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.

  22. 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!!

  23. 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?

  24. 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