mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge branch '3.2.x'
This commit is contained in:
@@ -491,7 +491,7 @@ function get_supported_image_types($type = false)
|
||||
*/
|
||||
function create_thumbnail($source, $destination, $mimetype)
|
||||
{
|
||||
global $config, $phpbb_filesystem;
|
||||
global $config, $phpbb_filesystem, $phpbb_dispatcher;
|
||||
|
||||
$min_filesize = (int) $config['img_min_thumb_filesize'];
|
||||
$img_filesize = (file_exists($source)) ? @filesize($source) : false;
|
||||
@@ -523,25 +523,31 @@ function create_thumbnail($source, $destination, $mimetype)
|
||||
return false;
|
||||
}
|
||||
|
||||
$used_imagick = false;
|
||||
$thumbnail_created = false;
|
||||
|
||||
// Only use ImageMagick if defined and the passthru function not disabled
|
||||
if ($config['img_imagick'] && function_exists('passthru'))
|
||||
{
|
||||
if (substr($config['img_imagick'], -1) !== '/')
|
||||
{
|
||||
$config['img_imagick'] .= '/';
|
||||
}
|
||||
/**
|
||||
* Create thumbnail event to replace GD thumbnail creation with for example ImageMagick
|
||||
*
|
||||
* @event core.thumbnail_create_before
|
||||
* @var string source Image source path
|
||||
* @var string destination Thumbnail destination path
|
||||
* @var string mimetype Image mime type
|
||||
* @var float new_width Calculated thumbnail width
|
||||
* @var float new_height Calculated thumbnail height
|
||||
* @var bool thumbnail_created Set to true to skip default GD thumbnail creation
|
||||
* @since 3.2.4
|
||||
*/
|
||||
$vars = array(
|
||||
'source',
|
||||
'destination',
|
||||
'mimetype',
|
||||
'new_width',
|
||||
'new_height',
|
||||
'thumbnail_created',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.thumbnail_create_before', compact($vars)));
|
||||
|
||||
@passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
|
||||
|
||||
if (file_exists($destination))
|
||||
{
|
||||
$used_imagick = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$used_imagick)
|
||||
if (!$thumbnail_created)
|
||||
{
|
||||
$type = get_supported_image_types($type);
|
||||
|
||||
|
Reference in New Issue
Block a user