Use web-thumbnailer to retrieve thumbnails

* requires PHP 5.6
  * use blazy on linklist since a lot more thumbs are retrieved
  * thumbnails can be disabled
  * thumbs size is now 120x120
  * thumbs are now cropped to fit the expected size

Fixes      
This commit is contained in:
ArthurHoaro 2016-11-09 18:57:02 +01:00
parent edb4a4d9c9
commit 1b93137e16
12 changed files with 222 additions and 427 deletions

51
tests/ThumbnailerTest.php Normal file
View file

@ -0,0 +1,51 @@
<?php
require_once 'application/Thumbnailer.php';
require_once 'application/config/ConfigManager.php';
/**
* Class ThumbnailerTest
*
* We only make 1 thumb test because:
*
* 1. the thumbnailer library is itself tested
* 2. we don't want to make too many external requests during the tests
*/
class ThumbnailerTest extends PHPUnit_Framework_TestCase
{
/**
* Test a thumbnail with a custom size.
*/
public function testThumbnailValid()
{
$conf = new ConfigManager('tests/utils/config/configJson');
$width = 200;
$height = 200;
$conf->set('thumbnails.width', $width);
$conf->set('thumbnails.height', $height);
$thumbnailer = new Thumbnailer($conf);
$thumb = $thumbnailer->get('https://github.com/shaarli/Shaarli/');
$this->assertNotFalse($thumb);
$image = imagecreatefromstring(file_get_contents($thumb));
$this->assertEquals($width, imagesx($image));
$this->assertEquals($height, imagesy($image));
}
/**
* Test a thumbnail that can't be retrieved.
*
* @expectedException WebThumbnailer\Exception\ThumbnailNotFoundException
*/
public function testThumbnailNotValid()
{
$oldlog = ini_get('error_log');
ini_set('error_log', '/dev/null');
$thumbnailer = new Thumbnailer(new ConfigManager());
$thumb = $thumbnailer->get('nope');
$this->assertFalse($thumb);
ini_set('error_log', $oldlog);
}
}

View file

@ -29,6 +29,9 @@
},
"plugins": {
"WALLABAG_VERSION": 1
},
"dev": {
"debug": true
}
}
*/ ?>