For instance I have a blog post that has the following iframe
.
<iframe width="420" height="315" src="//www.youtube.com/embed/1sIWez9HAbA" frameborder="0" allowfullscreen></iframe>
How can I extract the thumbnail from this iframe
?
For instance I have a blog post that has the following iframe
.
<iframe width="420" height="315" src="//www.youtube.com/embed/1sIWez9HAbA" frameborder="0" allowfullscreen></iframe>
How can I extract the thumbnail from this iframe
?
YouTube thumbnails
YouTube thumbnails can be found in this standard path:
[video-id]
is the YouTube video ID, e.g.1sIWez9HAbA
.[thumbnail-number]
is the number of the thumbnail of the 4 each video usually has, e.g.0
.Getting the thumbnail from an iframe
So, based on the
iframe
'ssrc
attribute you may construct the URL of the thumbnail directly.For example, using jQuery:
Note this example checks the URL of the
iframe
for a valid YouTube video ID and assumes it to be 11 characters long, which is the de facto standard.See jsFiddle Demo