FIX Creation of thumbs when images.lib.php was already included
This commit is contained in:
parent
b1536a639f
commit
1d235c2fd9
@ -5687,9 +5687,15 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function addThumbs($file)
|
public function addThumbs($file)
|
||||||
{
|
{
|
||||||
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ...
|
$tmparraysize = getDefaultImageSizes();
|
||||||
|
$maxwidthsmall = $tmparraysize['maxwidthsmall'];
|
||||||
|
$maxheightsmall = $tmparraysize['maxheightsmall'];
|
||||||
|
$maxwidthmini = $tmparraysize['maxwidthmini'];
|
||||||
|
$maxheightmini = $tmparraysize['maxheightmini'];
|
||||||
|
//$quality = $tmparraysize['quality'];
|
||||||
|
$quality = 50; // For thumbs, we force quality to 50
|
||||||
|
|
||||||
$file_osencoded = dol_osencode($file);
|
$file_osencoded = dol_osencode($file);
|
||||||
if (file_exists($file_osencoded)) {
|
if (file_exists($file_osencoded)) {
|
||||||
|
|||||||
@ -1690,10 +1690,16 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
|
|||||||
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles, $upload_dir);
|
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles, $upload_dir);
|
||||||
|
|
||||||
if (is_numeric($resupload) && $resupload > 0) { // $resupload can be 'ErrorFileAlreadyExists'
|
if (is_numeric($resupload) && $resupload > 0) { // $resupload can be 'ErrorFileAlreadyExists'
|
||||||
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
|
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||||
|
|
||||||
|
$tmparraysize = getDefaultImageSizes();
|
||||||
|
$maxwidthsmall = $tmparraysize['maxwidthsmall'];
|
||||||
|
$maxheightsmall = $tmparraysize['maxheightsmall'];
|
||||||
|
$maxwidthmini = $tmparraysize['maxwidthmini'];
|
||||||
|
$maxheightmini = $tmparraysize['maxheightmini'];
|
||||||
|
//$quality = $tmparraysize['quality'];
|
||||||
|
$quality = 50; // For thumbs, we force quality to 50
|
||||||
|
|
||||||
// Generate thumbs.
|
// Generate thumbs.
|
||||||
if ($generatethumbs) {
|
if ($generatethumbs) {
|
||||||
if (image_format_supported($destfull) == 1) {
|
if (image_format_supported($destfull) == 1) {
|
||||||
@ -1701,10 +1707,10 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
|
|||||||
// We can't use $object->addThumbs here because there is no $object known
|
// We can't use $object->addThumbs here because there is no $object known
|
||||||
|
|
||||||
// Used on logon for example
|
// Used on logon for example
|
||||||
$imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
|
$imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
|
||||||
// Create mini thumbs for image (Ratio is near 16/9)
|
// Create mini thumbs for image (Ratio is near 16/9)
|
||||||
// Used on menu or for setup page for example
|
// Used on menu or for setup page for example
|
||||||
$imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
|
$imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,12 +23,34 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Define size of logo small and mini
|
// Define size of logo small and mini
|
||||||
|
// TODO Remove this and call getDefaultImageSizes() instead
|
||||||
$maxwidthsmall = 480;
|
$maxwidthsmall = 480;
|
||||||
$maxheightsmall = 270; // Near 16/9eme
|
$maxheightsmall = 270; // Near 16/9eme
|
||||||
$maxwidthmini = 128;
|
$maxwidthmini = 128;
|
||||||
$maxheightmini = 72; // 16/9eme
|
$maxheightmini = 72; // 16/9eme
|
||||||
$quality = 80;
|
$quality = 80;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return default values for image sizes
|
||||||
|
*
|
||||||
|
* @return array Array of default values
|
||||||
|
*/
|
||||||
|
function getDefaultImageSizes()
|
||||||
|
{
|
||||||
|
$maxwidthsmall = 480;
|
||||||
|
$maxheightsmall = 270; // Near 16/9eme
|
||||||
|
$maxwidthmini = 128;
|
||||||
|
$maxheightmini = 72; // 16/9eme
|
||||||
|
$quality = 80;
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'maxwidthsmall' => $maxwidthsmall,
|
||||||
|
'maxheightsmall' => $maxheightsmall,
|
||||||
|
'maxwidthmini' => $maxwidthmini,
|
||||||
|
'maxheightmini' => $maxheightmini,
|
||||||
|
'quality' => $quality
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if a filename is file name of a supported image format
|
* Return if a filename is file name of a supported image format
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user