JavaScript is disabled! Please enable JavaScript in your web browser!

Freestyle Academy of Communication Arts & Technology

1325 Bryant Ave, Mt. View, CA 94040 T 650-940-4650 x0090
2 Required Classes: English and Digital Media 3rd/Elective Class:  + Animation or Design or Film

Back to list of all examples

Useful Stuff About:

Image Thumbnail that Expands to Show Video

Version 1 | Version 2 | Version 3 | Version 4 | Version 5

Click on the video thumbnail below to see the demo.

Play Video

This example uses any image of any reasonable size for the thumbnail. When the <figure id="vidThumbnail"></figure> gets clicked, the script executes to resize the figure tag and the img inside the figure tag to the custom target width and height of the video. When the correct dimensions have been reached, the img gets removed and the video is then display. The script recognizes when the video is completed, then the video is replaced with the original image and then reduced down to its original thumbnail dimension. Watch the video till the end to see the effect.

This script is targeted only for YouTube videos (rather than HTML5 videos served up from your own webserver) of any custom size.

Optional: Create the thumbnail with "Play Video" or the play symbol in the image and you don't need any text inside the figcaption tag.


Scripts needed (copy and paste inside <head>)

<script type="text/javascript" src=""></script><!--ONLY ONE OF THESE IN THE HEAD!!!!!-->
<script src=""></script><!--ONLY ONE OF THESE IN THE HEAD!!!!!!-->
//Set variables specific to your target YouTube Video where
//vidExpandTime is the target time to change from thumbnail to video
//vidPlayerEasing options through

var vidExpandTime = 1000, vidID = "0Bmhjf0rKe8", vidPlayerEasing = "easeInOutCirc";

<script src=""></script><!--ONLY ONE OF THESE IN THE HEAD!!!!!!--->
<script src=""></script><!--REQUIRED!!!!!!-->


Here's the html code

<!--This block below must be INSIDE the centeringDiv-->
<figure id="vidThumbnail">
<img src="pathToYour/videoThumbnail.jpg"/>
<div id="vidPlayer"></div>
Play Video<!--OPTIONAL-->
This is the text content that would wrap around the video thumbnail.


Here's the CSS

#vidThumbnail {/* for the video thumbanil container */
margin:5px 20px 20px 0;/*TRBL = Top Right Bottom Left*/
width:200px;/* Adjust as needed */
height:150px;/* Adjust as needed */
#vidThumbnail img {/* dimensions of video thumbnail */
width:200px;/* Adjust as needed */
height:150px;/* Adjust as needed */
#vidThumbnail figcaption {/* for the text on TOP of video thumbnail */