From c2f6c2680330ad40f80a4cfe68388ece8dd313ec Mon Sep 17 00:00:00 2001 From: Emilien Klein Date: Wed, 18 Jan 2012 21:31:12 +0100 Subject: Added: Support for xkcd thumbnails --- index.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 011aeed9..ba3d9c34 100644 --- a/index.php +++ b/index.php @@ -1484,12 +1484,14 @@ function thumbnail($url,$href=false) if ($domain=='flickr.com' || endsWith($domain,'.flickr.com') || $domain=='vimeo.com' || $domain=='ted.com' || endsWith($domain,'.ted.com') + || $domain=='xkcd.com' || endsWith($domain,'.xkcd.com') ) { - if ($domain=='vimeo.com') - { // Make sure this vimeo url points to a video (/xxx... where xxx is numeric) + if ($domain=='vimeo.com' || $domain=='xkcd.com' || endsWith($domain,'.xkcd.com')) + { // Make sure the url is of the form /xxx... where xxx is numeric + // For Vimeo's videos and xkcd's comics $path = parse_url($url,PHP_URL_PATH); - if (!preg_match('!/\d+.+?!',$path)) return ''; // This is not a single video URL. + if (!preg_match('!/\d+.+?!',$path)) return ''; // This is not a single video/comic URL. } if ($domain=='ted.com' || endsWith($domain,'.ted.com')) { // Make sure this TED url points to a video (/talks/...) @@ -1797,6 +1799,35 @@ function genThumbnail() } } + elseif ($domain=='xkcd.com' || endsWith($domain,'.xkcd.com')) + { + // There is no thumbnail available for xkcd comics, so download the whole image and resize it. + // http://xkcd.com/327/ + // <BLABLA> + list($httpstatus,$headers,$data) = getHTTP($url,5); + if (strpos($httpstatus,'200 OK')!==false) + { + // Extract the link to the thumbnail + preg_match('!