how to control youtube video width/height thumb with wordpress?

/********************************************************************
show any video (control width/height)
********************************************************************/
define(“YOUTUBE_TARGET”, “<object width=\”###WIDTH###\” height=\”###HEIGHT###\”><param name=\”movie\” value=\”http://www.youtube.com/v/###URL###?fs=1&amp;hl=en_US\”></param><param name=\”allowFullScreen\” value=\”true\”></param><param name=\”allowscriptaccess\” value=\”always\”></param><embed src=\”http://www.youtube.com/v/###URL###?fs=1&amp;hl=en_US\” type=\”application/x-shockwave-flash\” allowscriptaccess=\”always\” allowfullscreen=\”true\” width=\”###WIDTH###\” height=\”###HEIGHT###\”></embed></object>”);
define(“YOUTUBE_IMAGE”, “<img src=\”http://img.youtube.com/vi/###URL###/hqdefault.jpg\” width=\”###WIDTH###\” height=\”###HEIGHT###\”/>”);

function show_video($args,$width,$height,$showtitle,$showimage) {
//’cat=37&posts_per_page=1&orderby=date&order=Desc’
query_posts($args);
if( have_posts() ) {
while( have_posts() ) {
the_post();

$filtered_content = str_replace(‘<p>’,”,get_the_content());
$filtered_content = str_replace(‘</p>’,”,$filtered_content);
$filtered_content=rtrim($filtered_content, “]”);
$filtered_content=ltrim($filtered_content, “[“);
if(!$showimage)
$output = YOUTUBE_TARGET;
else
$output = YOUTUBE_IMAGE;

$output = str_replace(“###URL###”, $filtered_content, $output);
$output = str_replace(“###WIDTH###”,$width, $output);
$output = str_replace(“###HEIGHT###”, $height, $output);
print     $output;

if($showtitle){
print ‘<a href=”‘;
the_permalink();
print ‘” title=”‘;
print the_title();
print ‘”>’;
print the_title_limit(220, ”);
print ‘</a>’;
}
}}
wp_reset_query();
}

How to get thumbnail of YouTube video link using YouTube API?

Each YouTube video has 4 generated images. They are predictably formatted as follows:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg

The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg

For the high quality version of the thumbnail use a url similar to this:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg

For the maximum resolution version of the thumbnail use a url similar to this:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg

Alternatively, you can use the YouTube API to get thumbnail images