Get youtube video screenshot using simple php and javascript
Simple script to get the screenshot of a particular URL from youtube,
<script type="text/javascript">
function getScreen( url, size ) {
if(url === null){
return "";
}
size = (size === null) ? "big" : size;
var vid;
var results;
results = url.match("[\\?&]v=([^&#]*)");
vid = ( results === null ) ? url : results[1];
if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg"; }
else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg"; }
}
</script>
< ?php $url = "http://www.youtube.com/watch?v=hQVTIJBZook";
echo $url;
?>
<script type="text/javascript">
var imgUrlbig = getScreen("< ?php echo $url ?>");
var imgUrlsmall = getScreen("< ?php echo $url ?>", 'small');
document.write('<img src="' + imgUrlbig + '" />');
document.write('<img src="' + imgUrlsmall + '" />');
</script>
Related posts:
- Embedding youtube video in wordpress
- Javascript Events A Complete Video Tutorial With Yahoo
- Simple Ajax with PHP click tracker

Fantastic post mate, helped me out a lot. Keep up the great posts.