youtube thumb Don't you just hate it when you visit somebody's blog, see an embedded Youtube video, play it, and find that the player is missing the full screen button.

Yeah, this one: youtube fullscreen button.

Well, I hate it too, so please, try not to be that guy. I realize sometimes you copy the embed code wrong or, on a larger scale, you add the wrong embed code to your generic template.

Not a problem. If your Youtube embeds are missing this button, here is how you can easily fix it.

The Problem

Here's an example video that doesn't have the button (it's really good too, if you haven't seen it yet):

The fullscreen button is nowhere to be found because by default the Youtube player doesn't include it and the embed code is missing the correct pieces.

Here is the embed code for the video above without the full screen button:

<object width="425" height="344">
  <param
    name="movie"
    value="http://www.youtube.com/v/sdUUx5FdySs&hl=en_US">
  </param>
  <param
    name="allowscriptaccess"
    value="always">
  </param>
  <embed
    src="http://www.youtube.com/v/sdUUx5FdySs&hl=en_US"
    type="application/x-shockwave-flash"
    allowscriptaccess="always"
    width="425"
    height="344">
  </embed>
</object>

The Solution

Modify the code by adding the following:

  • put this after the last <param> and before the <embed>: <param name="allowFullScreen" value="true"></param>
  • add this after any parameter to <embed>: allowfullscreen="true"
  • append this to both the "value" parameter of the <param> tag with the name="movie" as well as the src parameter of the <embed> tag: &fs=1

The first 2 parameters give Flash access to go full screen. The last one instructs the Youtube player to add the full screen button.

Here is the final embed code:

&lt;object width=&quot;425&quot; height=&quot;344&quot;&gt;
  &lt;param
    name=&quot;movie&quot;
    value=&quot;http://www.youtube.com/v/sdUUx5FdySs&amp;hl=en_US&amp;fs=1&quot;&gt;
  &lt;/param&gt;
  &lt;param
    name=&quot;allowscriptaccess&quot;
    value=&quot;always&quot;&gt;
  &lt;/param&gt;
  &lt;param
    name=&quot;allowFullScreen&quot;
    value=&quot;true&quot;&gt;
  &lt;/param&gt;
  &lt;embed
    src=&quot;http://www.youtube.com/v/sdUUx5FdySs&amp;hl=en_US&amp;fs=1&quot;
    type=&quot;application/x-shockwave-flash&quot;
    allowscriptaccess=&quot;always&quot;
    allowfullscreen=&quot;true&quot;
    width=&quot;425&quot;
    height=&quot;344&quot;&gt;
  &lt;/embed&gt;
&lt;/object&gt;

Voila!

By the way, if you are wondering why you have to include both the object and embed tags, duplicating parameters left and right, well, it's to satisfy both IE and other browsers. Firefox, for example, uses the embed part, while IE uses the object one.

● ● ●
Artem Russakovskii is a San Francisco programmer and blogger. Follow Artem on Twitter (@ArtemR) or subscribe to the RSS feed.

In the meantime, if you found this article useful, feel free to buy me a cup of coffee below.