Revision: 29913
Updated Code
at August 25, 2010 07:05 by Jamie
Updated Code
/** * Creates a YouTube thumbnail URL from a YouTube video URL */ function youtube_video_thumbnail($url,$index=0){ if(preg_match('/^[^v]+v.(.{11}).*/',$url,$matches)){ return 'http://img.youtube.com/vi/'.$matches[1].'/'.$index.'.jpg'; }elseif(preg_match('/youtube.com\/user\/(.*)\/(.*)$/',$url,$matches)){ return 'http://img.youtube.com/vi/'.$matches[2].'/'.$index.'.jpg'; }else{ return false; } }
Revision: 29912
Updated Code
at August 6, 2010 02:18 by Jamie
Updated Code
/** * Creates a Yoututbe thumbnial URL from a YouTube video URL */ function youtube_video_thumbnail($url){ if(preg_match('/^[^v]+v.(.{11}).*/',$url,$matches)){ return 'http://img.youtube.com/vi/'.$matches[1].'/0.jpg'; }else{ return false; } }
Revision: 29911
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 5, 2010 03:09 by Jamie
Initial Code
/^[^v]+v.(.{11}).*/
Initial URL
Initial Description
I\'ve added an additional case to handle videos linked from a user\'s channel.
Initial Title
Youtube Video ID Regex & PHP Function
Initial Tags
regex, php, video
Initial Language
PHP