Wednesday, December 28, 2011

Display a thumbnail from a Youtube using a shortcode

 How to display a thumbnail from a Youtube using a shortcode

Copy the following code below and then paste it into the functions.php file under theme folder.

    THis Shortcode will display youtube thumbnail on the wordpress blog.
    [youtube_thumb id="VIDEO_ID" img="0" align="left"]
    VIDEO_ID= Youtube video id
    img=0,1,2 or 3
    align= left,right,center
function wp_youtube_video_thumbnail($atts) {
          'id' => '',
          'img' => '0',
     ), $atts));
add_shortcode('youtube_thumb', 'wp_youtube_video_thumbnail');

Now, you can use the shortcode. The shortcode accept 3 parameters: The video ID, the image size (0 for 480*360px, 1 for 120*90) and the image alignment.

[youtube_thumb id="8O9YA7PZZe0" img="0" align="center"]

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off