mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/8672] Use fastImageSize in classes
PHPBB3-8672
This commit is contained in:
parent
3fc7a352ff
commit
39d6180c68
10 changed files with 18 additions and 18 deletions
|
@ -203,7 +203,7 @@ services:
|
|||
class: phpbb\template\context
|
||||
|
||||
upload_imagesize:
|
||||
class: phpbb\upload\imagesize
|
||||
class: fastImageSize\fastImageSize
|
||||
|
||||
version_helper:
|
||||
class: phpbb\version_helper
|
||||
|
|
|
@ -401,9 +401,9 @@ class filespec
|
|||
$this->width = $this->height = 0;
|
||||
|
||||
// Get imagesize class
|
||||
$imagesize = new \phpbb\upload\imagesize();
|
||||
$imagesize = new \fastImageSize\fastImageSize();
|
||||
|
||||
$this->image_info = $imagesize->get_imagesize($this->destination_file, $this->mimetype);
|
||||
$this->image_info = $imagesize->getImageSize($this->destination_file, $this->mimetype);
|
||||
|
||||
if ($this->image_info !== false)
|
||||
{
|
||||
|
|
|
@ -339,8 +339,8 @@ class bbcode_firstpass extends bbcode
|
|||
|
||||
if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width'])
|
||||
{
|
||||
$imagesize = new \phpbb\upload\imagesize();
|
||||
$size_info = $imagesize->get_imagesize(htmlspecialchars_decode($in));
|
||||
$imagesize = new \fastImageSize\fastImageSize();
|
||||
$size_info = $imagesize->getImageSize(htmlspecialchars_decode($in));
|
||||
|
||||
if ($size_info === false)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
|
|||
*/
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\upload\imagesize */
|
||||
/** @var \fastImageSize\fastImageSize */
|
||||
protected $imagesize;
|
||||
|
||||
/**
|
||||
|
@ -76,13 +76,13 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
|
|||
* Construct a driver object
|
||||
*
|
||||
* @param \phpbb\config\config $config phpBB configuration
|
||||
* @param \phpbb\upload\imagesize $imagesize phpBB imagesize class
|
||||
* @param \fastImageSize\fastImageSize $imagesize fastImageSize class
|
||||
* @param string $phpbb_root_path Path to the phpBB root
|
||||
* @param string $php_ext PHP file extension
|
||||
* @param \phpbb\path_helper $path_helper phpBB path helper
|
||||
* @param \phpbb\cache\driver\driver_interface $cache Cache driver
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\upload\imagesize $imagesize, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null)
|
||||
public function __construct(\phpbb\config\config $config, \fastImageSize\fastImageSize $imagesize, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->imagesize = $imagesize;
|
||||
|
|
|
@ -108,7 +108,7 @@ class gravatar extends \phpbb\avatar\driver\driver
|
|||
$row['avatar_width'] = $row['avatar_height'] = min($this->config['avatar_max_width'], $this->config['avatar_max_height']);
|
||||
$url = $this->get_gravatar_url($row);
|
||||
|
||||
if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = $this->imagesize->get_imagesize($url)) === false))
|
||||
if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = $this->imagesize->getImageSize($url)) === false))
|
||||
{
|
||||
$error[] = 'UNABLE_GET_IMAGE_SIZE';
|
||||
return false;
|
||||
|
|
|
@ -172,7 +172,7 @@ class local extends \phpbb\avatar\driver\driver
|
|||
// Match all images in the gallery folder
|
||||
if (preg_match('#^[^&\'"<>]+\.(?:' . implode('|', $this->allowed_extensions) . ')$#i', $image) && is_file($file_path . '/' . $image))
|
||||
{
|
||||
$dims = $this->imagesize->get_imagesize($file_path . '/' . $image);
|
||||
$dims = $this->imagesize->getImageSize($file_path . '/' . $image);
|
||||
|
||||
if ($dims === false)
|
||||
{
|
||||
|
|
|
@ -93,7 +93,7 @@ class remote extends \phpbb\avatar\driver\driver
|
|||
}
|
||||
|
||||
// Get image dimensions
|
||||
if (($width <= 0 || $height <= 0) && (($image_data = $this->imagesize->get_imagesize($url)) === false))
|
||||
if (($width <= 0 || $height <= 0) && (($image_data = $this->imagesize->getImageSize($url)) === false))
|
||||
{
|
||||
$error[] = 'UNABLE_GET_IMAGE_SIZE';
|
||||
return false;
|
||||
|
|
|
@ -374,8 +374,8 @@ class parser implements \phpbb\textformatter\parser_interface
|
|||
|
||||
if ($max_height || $max_width)
|
||||
{
|
||||
$imagesize = new \phpbb\upload\imagesize();
|
||||
$size_info = $imagesize->get_imagesize($url);
|
||||
$imagesize = new \fastImageSize\fastImageSize();
|
||||
$size_info = $imagesize->getImageSize($url);
|
||||
if ($size_info === false)
|
||||
{
|
||||
$logger->err('UNABLE_GET_IMAGE_SIZE');
|
||||
|
|
|
@ -57,7 +57,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
|||
new \phpbb\mimetype\content_guesser,
|
||||
);
|
||||
$guesser = new \phpbb\mimetype\guesser($guessers);
|
||||
$imagesize = new \phpbb\upload\imagesize();
|
||||
$imagesize = new \fastImageSize\fastImageSize();
|
||||
|
||||
// $this->avatar_foobar will be needed later on
|
||||
$this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache));
|
||||
|
|
|
@ -16,7 +16,7 @@ require_once(__DIR__ . '/../../phpBB/includes/functions.php');
|
|||
|
||||
class phpbb_upload_imagesize_test extends \phpbb_test_case
|
||||
{
|
||||
/** @var \phpbb\upload\imagesize */
|
||||
/** @var \fastImageSize\fastImageSize */
|
||||
protected $imagesize;
|
||||
|
||||
/** @var string Path to fixtures */
|
||||
|
@ -25,7 +25,7 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case
|
|||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->imagesize = new \phpbb\upload\imagesize();
|
||||
$this->imagesize = new \fastImageSize\fastImageSize();
|
||||
$this->path = __DIR__ . '/fixture/';
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case
|
|||
*/
|
||||
public function test_get_imagesize($file, $mime_type, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->imagesize->get_imagesize($this->path . $file, $mime_type));
|
||||
$this->assertEquals($expected, $this->imagesize->getImageSize($this->path . $file, $mime_type));
|
||||
}
|
||||
|
||||
public function test_get_imagesize_remote()
|
||||
|
@ -94,6 +94,6 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case
|
|||
'height' => 80,
|
||||
'type' => IMAGETYPE_JPEG,
|
||||
),
|
||||
$this->imagesize->get_imagesize('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'));
|
||||
$this->imagesize->getImageSize('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue