Getting YouTube video screenshot

May 14, 2009 | No Comments
Share |

originally taken from here

http://jquery-howto.blogspot.com/2009/02/how-to-get-youtube-video-screenshot.html

A great little way of getting the any video link from a youtube video
cool uses


<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  $message = "http://www.youtube.com/watch?v=iIp7OnHXBlo";
echo $message;
 ?>

<script type="text/javascript">

var imgUrl_big = getScreen("<?php echo $message ?>");
var imgUrl_small = getScreen("<?php echo $message ?>", 'small');

document.write('<img src="' + imgUrl_big + '" />');
document.write('<img src="' + imgUrl_small + '" />');

</script>
May 14, 2009 | No Comments
Share |

Leave a Reply