Created
May 13, 2012 21:03
-
-
Save omgmog/2690184 to your computer and use it in GitHub Desktop.
jQuery snippet for embedding YouTube videos with custom thumbnails
This file contains 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
$(function(){ | |
$('.ytembed:not(.processed)').addClass('processed').each(function() { | |
$(this).find('a').click(function(e) { | |
e.preventDefault(); | |
var width = $(this).find('img').width(); | |
var height = $(this).find('img').height(); | |
var url = $(this).attr('href'); | |
var $iframe = $('<iframe src="'+url+'" width="'+width+'" height="'+height+'" frameborder="0"/>'); | |
$(this).parent().html($iframe); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment