Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTube embedded video: set different thumbnail

Tags:

youtube

video

I want to embed a video from YouTube that is not mine (so I can not change it at YouTube). The video has a thumbnail that is not representative for the video (I refer to the initial still that is shown when you embed a video, shown before the user plays it).

Is there a way to set the time of the still, for instance I tried passing ?s=XXX but this does not work. Or another way that comes natively with YouTube?

like image 202
user852091 Avatar asked Aug 26 '11 03:08

user852091


People also ask

How do you add a thumbnail to a YouTube video in HTML?

This can be simply done by using the poster attribute. All you have to do is create a poster attribute in the video tag and place the URL of the thumbnail image in it.


1 Answers

There's a nice workaround for this in the sitepoint forums:

<div onclick="this.nextElementSibling.style.display='block'; this.style.display='none'">    <img src="my_thumbnail.png" style="cursor:pointer" /> </div> <div style="display:none">     <!-- Embed code here --> </div> 

Note: To prevent having to click twice to make the video play, use autoplay=1 in the video embed code. It will start playing when the second div is displayed.

like image 128
waldyrious Avatar answered Oct 05 '22 23:10

waldyrious