This solution to embed a YouTube-Player in your WordPress-Theme was used to show just a preview image and on click play the video in a lightbox. For the lightbox I used the Easy-Fancybox Plugin.
Here is my theme function:
function youtube_shortcode_handler( $atts, $content = null ) {
extract( shortcode_atts( array(
'size' => 'big', // the image size, just for css styling
'id' => 'tOhU7wqWV3E', // the youtube ID
// ...etc
), $atts ) );
// check for highest resolution preview image from youtube, the @ disables warnings
if(@file_get_contents('http://img.youtube.com/vi/'. $id .'/maxresdefault.jpg')) {
$youtube_img = 'http://img.youtube.com/vi/'. $id .'/maxresdefault.jpg';
}
// if highest resolution dosn't exists check for the next
else if(@file_get_contents('http://img.youtube.com/vi/'. $id .'/hqdefault.jpg')) {
$youtube_img = 'http://img.youtube.com/vi/'. $id .'/hqdefault.jpg';
}
// no high resolution preview images - take the default
else {
$youtube_img = 'http://img.youtube.com/vi/'. $id .'/0.jpg';
}
// check for content as title
if($content) $title = '<div><h2><span>'. $content .'</span></h2></div>'; else $title= '';
// return html markup
return '<div class="youtube '.$size.'"><a href="http://www.youtube.com/embed/'. $id .'?autoplay=1&wmode=transparent">'. $title .'<div><img src="'. $youtube_img .'" alt="'. $content .'"></div></a></div>';
}
add_shortcode( 'youtube', 'youtube_shortcode_handler' );
Now you can use this shortcode in your editor:

This will generate the following markup and you can easy style it with CSS. I know the markup can be much more simple, but this was for a special case.
<div class="youtube medium">
<a href="http://www.youtube.com/embed/2gq8cwj-Exc?autoplay=1&wmode=transparent">
<div><h2><span>DER HOBBIT Trailer German Deutsch | FullHD 2012</span></h2></div>
<div><img src="http://img.youtube.com/vi/2gq8cwj-Exc/maxresdefault.jpg" alt="DER HOBBIT Trailer German Deutsch | FullHD 2012"></div>
</a>
</div>
This is the result of the shortcode below without any additional styling. Here you can find a real example with some styling and a play button: http://www.optegra-deutschland.de/ueber-uns/movies/
Don’t forget to enable Easy-Fancybox for YouTube on the plugin settings page.