By default, embedded YouTube videos are 425 pixels wide, which is wider than the content column on Choking on Popcorn. To be able to easily resize and add cool videos to that site I copy-pasted together a very basic plugin for WordPress. It allows you to simply use something like [youtube ]xxxxxxxxx[/youtube] to embed the video. The ‘xxxxxxxxx’ bit needs to be replaced with the actual video’s ID of course. I know there are tons of plugins that do similar things and are vastly superior, but this one suits my needs perfectly.
The output is valid XHTML, and you can adjust the display size by editing the plugin a bit. The entire thing is only a few lines so you’ll have no trouble finding the dimensions in the code.
Simply replace the numbers 425 (width) and 350 (height) with numbers that fit your site’s layout. Simply use the options panel under Options -> Youtuber.
Feel free to download it and play around with it a bit. If you make improvements or can think of a cooler name for the plugin, please let me know.
- Download the zip file and unpack the file inside.
- Upload this file to the wp-content/plugins folder on your server.
- Activate it on WordPress’s ‘plugins’ tab.
To embed a video using the plugin, follow these steps:
- Find the video on YouTube.
- Extract the ID fromthe video page url. These look something like: http://youtube.com/watch?v=Krhl2o_uwdc. The bit I put in bold type is the ID.
- Type [youtube ]Krhl2o_uwdc[/youtube] anywhere in your post. Leave out the space in the first tag.
- Save and publish the post.
To change the display resolution for the videos:
Open youtuber.php in a text editor (I use Notepad++) Find the numbers 425 and 350. Replace these numbers with your preferred display dimensions. The control bar underneath the video is about 20 pixels high, so the height should ideally be 3/4 of the width plus 20 pixels. Save the file and (re)upload to your plugins folder.
- Go to Options -> Youtuber and type in the values that work for your blog.
- Version 1.3 was the first to be hosted on WordPress.org, and released under GPL.
- Version 1.2 adds better default values, case insensitive tags, and fixes an issue with WPMU.
- Version 1.1 adds a basic options panel.
- Version 1.0 was the initial release.