Wordpress supports auto-embeds: certain links are automatically converted into embed widgets. Embedding YouTube videos is done by simply pasting the URL. Unfortunately the video quality is low by default. It’s possible to specify the quality using the vq parameter. Auto-embeds don’t support parameters, though. There is a way to manipulate the generated html code by adding parameters to each embedded YouTube video automatically.

Just add the following code to functions.php in your theme folder:

/* Play YouTube videos in the best quality available. */
function oembed_hd( $html, $url, $attr, $post_id ) {
if ( strpos ( $html, 'feature=oembed' ) !== false )
return str_replace( 'feature=oembed',
'feature=oembed&rel=0&vq=hd1080', $html );
else
return $html;
}
add_filter('embed_oembed_html', 'oembed_hd', 10, 4 );

The parameters explained:

  • rel=0 - Hides related videos.
  • vq=hd1080 - Forces a 1080p quality. Uses the best quality, if 1080p is not available.

Update 27.02.2014

This method is deprecated. Currently there is no official method to force HD resolution in embedded YouTube videos.

Update 17.03.2015

It’s now possible to force HD videos again.
The first method is to use embed instead of iframe (Source):

<object width="560" height="315">
<param name="movie" value="//www.youtube.com/v/VIDEOID?hl=en_US&amp;version=3&amp;vq=hd1080">
<param name="allowFullScreen" value="true">
<param name="allowscriptaccess" value="always">
<embed src="//www.youtube.com/v/VIDEOID?hl=en_US&amp;version=3&amp;vq=hd1080" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>

The second method is using the official YouTube JS API (check out this demo).