Created
April 30, 2009 22:43
-
-
Save mmb/104747 to your computer and use it in GitHub Desktop.
prepend youtube links with 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 add_youtube_thumbs() { | |
var m; | |
$('a').map(function() { | |
m = /http:\/\/(?:(?:www|uk)\.)?youtube\.com\/watch\?v=(.+?)(?:&|$)/.exec( | |
$(this).attr('href')); | |
if (m) { | |
$(this).prepend($('<img />').attr({ | |
'class' : 'youtube_thumb', | |
'src' : 'http://img.youtube.com/vi/' + m[1] + '/1.jpg' | |
})); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment