Created
June 3, 2017 05:41
-
-
Save vaporic/8045725ad9de9749ef4335cc63589a1e to your computer and use it in GitHub Desktop.
visualizar thumbnail de youtube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<iframe width="420" height="315" src="//www.youtube.com/embed/1sIWez9HAbA" frameborder="0" allowfullscreen></iframe> | |
<div>Click the thumbnail</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var iframe = $('iframe:first'); | |
var iframe_src = iframe.attr('src'); | |
var youtube_video_id = iframe_src.match(/youtube\.com.*(\?v=|\/embed\/)(.{11})/).pop(); | |
if (youtube_video_id.length == 11) { | |
var video_thumbnail = $('<img src="//img.youtube.com/vi/'+youtube_video_id+'/0.jpg">'); | |
$('body').append(video_thumbnail); | |
$('img:first').click(function() { | |
$('iframe:first').fadeToggle('400'); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div {float:left;margin:20px;} | |
iframe {display:none;} | |
img {float:left;width:120px;height:90px;cursor:pointer;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment