From 8f2c12ce6aeda25177d75c8269b84310d3d5c3f3 Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Tue, 19 Mar 2013 17:22:50 +0100 Subject: [PATCH] [add] option for use external service for thumbshot --- .gitignore | 3 ++- index.php | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index bcd745e..02dd862 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ pagecache # Eclipse project files .settings .buildpath -.project \ No newline at end of file +.project +inc/user.css \ No newline at end of file diff --git a/index.php b/index.php index 1d13e55..80623ed 100644 --- a/index.php +++ b/index.php @@ -11,7 +11,7 @@ date_default_timezone_set('UTC'); // ----------------------------------------------------------------------------------------------- -// Hardcoded parameter (These parameters can be overwritten by creating the file /config/options.php) +// Hardcoded parameter (These parameters can be overwritten by creating the file /YourDataDir/options.php see next line) $GLOBALS['config']['DATADIR'] = 'data'; // Data subdirectory $GLOBALS['config']['CONFIG_FILE'] = $GLOBALS['config']['DATADIR'].'/config.php'; // Configuration file (user login/password) $GLOBALS['config']['DATASTORE'] = $GLOBALS['config']['DATADIR'].'/datastore.php'; // Data storage file. @@ -29,6 +29,9 @@ $GLOBALS['config']['PUBSUBHUB_URL'] = ''; // PubSubHubbub support. Put an empty $GLOBALS['config']['UPDATECHECK_FILENAME'] = $GLOBALS['config']['DATADIR'].'/lastupdatecheck.txt'; // For updates check of Shaarli. $GLOBALS['config']['UPDATECHECK_INTERVAL'] = 86400 ; // Updates check frequency for Shaarli. 86400 seconds=24 hours // Note: You must have publisher.php in the same directory as Shaarli index.php +$GLOBALS['config']['externalThumbshot'] = ''; // Url for external thumbnailer + // exemple : http://images.thumbshots.com/image.aspx?cid=dgdfgdfg&v=1&w=120&url= + // the last param must be a url // ----------------------------------------------------------------------------------------------- // You should not touch below (or at your own risks !) // Optionnal config file. @@ -1863,7 +1866,9 @@ function computeThumbnail($url,$href=false) if ($domain=='imgur.com') { $path = parse_url($url,PHP_URL_PATH); - if (startsWith($path,'/a/')) return array(); // Thumbnails for albums are not available. + if (startsWith($path,'/a/') && empty($GLOBALS['config']['externalThumbshot'])){ + return array(); // Thumbnails for albums are not available. + } if (startsWith($path,'/r/')) return array('src'=>'http://i.imgur.com/'.basename($path).'s.jpg', 'href'=>$href,'width'=>'90','height'=>'90','alt'=>'imgur.com thumbnail'); if (startsWith($path,'/gallery/')) return array('src'=>'http://i.imgur.com'.substr($path,8).'s.jpg', @@ -1897,6 +1902,11 @@ function computeThumbnail($url,$href=false) 'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'imageshack.us thumbnail'); } } + if(!empty($GLOBALS['config']['externalThumbshot']) && $GLOBALS['config']['ENABLE_THUMBNAILS'] !== false) + { + $thumburl = $GLOBALS['config']['externalThumbshot'].urlencode($url); + return array('src'=>$thumburl,'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'Custom Thumbshot'); + } // Some other hosts are SLOW AS HELL and usually require an extra HTTP request to get the thumbnail URL. // So we deport the thumbnail generation in order not to slow down page generation