diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index f17ca46299f..e8c5749088a 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -356,13 +356,8 @@ if (empty($reshook))
}
else
{
- // Create small thumbs for company (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
-
- // Create mini thumbs for company (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
+ // Create thumbs
+ $object->addThumbs($newfile);
}
}
}
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index 849916222dd..c9e07677512 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -98,12 +98,14 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
// Create thumbs of logo (Note that PDF use original file and not thumbs)
if ($isimage > 0)
{
- // Create small thumbs for company (Ratio is near 16/9)
+ // Create thumbs
+ //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retreive value with get...
+
// Used on logon for example
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
- if (preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg))
+ if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg))
{
- $imgThumbSmall = $reg[1];
+ $imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall,'chaine',0,'',$conf->entity);
}
else dol_syslog($imgThumbSmall);
@@ -111,9 +113,9 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
- if (preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg))
+ if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg))
{
- $imgThumbMini = $reg[1];
+ $imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini,'chaine',0,'',$conf->entity);
}
else dol_syslog($imgThumbMini);
@@ -203,12 +205,14 @@ if ($action == 'addthumb')
// Create thumbs of logo
if ($isimage > 0)
{
- // Create small thumbs for company (Ratio is near 16/9)
+ // Create thumbs
+ //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retreive value with get...
+
// Used on logon for example
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small',$quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg))
{
- $imgThumbSmall = $reg[1];
+ $imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall,'chaine',0,'',$conf->entity);
}
else dol_syslog($imgThumbSmall);
@@ -218,7 +222,7 @@ if ($action == 'addthumb')
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini',$quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg))
{
- $imgThumbMini = $reg[1];
+ $imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini,'chaine',0,'',$conf->entity);
}
else dol_syslog($imgThumbMini);
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 3406876e54e..090177af5ac 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -1451,8 +1451,8 @@ class Categorie extends CommonObject
if (file_exists($originImage))
{
- // Cree fichier en taille vignette
- $this->add_thumb($originImage);
+ // Create thumbs
+ $this->addThumbs($originImage);
}
}
}
diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php
index f3a84eed5d5..783326c1e4f 100644
--- a/htdocs/categories/photos.php
+++ b/htdocs/categories/photos.php
@@ -79,7 +79,7 @@ if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->
if ($action == 'addthumb' && $_GET["file"])
{
- $object->add_thumb($upload_dir."/".$_GET["file"]);
+ $object->addThumbs($upload_dir."/".$_GET["file"]);
}
diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php
index 4964f517e46..7320ce85f91 100644
--- a/htdocs/compta/bank/document.php
+++ b/htdocs/compta/bank/document.php
@@ -92,18 +92,10 @@ if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) {
$upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),
0, 0, $_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0) {
- if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name'])
- == 1) {
- // Create small thumbs for image (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'],
- $maxwidthsmall, $maxheightsmall, '_small', $quality,
- "thumbs");
- // Create mini thumbs for image (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'],
- $maxwidthmini, $maxheightmini, '_mini', $quality,
- "thumbs");
+ if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
+ {
+ // Create thumbs
+ $object->addThumbs($upload_dir . "/" . $_FILES['userfile']['name']);
}
$mesg = '
' . $langs->trans("FileTransferComplete") . '
';
}
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index cc67393d679..5dbeeb951dd 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -314,13 +314,9 @@ if (empty($reshook))
else
{
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
- // Create small thumbs for company (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
- // Create mini thumbs for company (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
+ // Create thumbs
+ $object->addThumbs($newfile);
}
}
}
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index dc5db9445bb..da70bc3e007 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -87,13 +87,8 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact
}
else
{
- // Create small thumbs for company (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
-
- // Create mini thumbs for company (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
+ // Create thumbs
+ $object->addThumbs($newfile);
}
}
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index c138ec07f09..f70f7dffea8 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -3910,7 +3910,7 @@ abstract class CommonObject
* @param string $file Path file in UTF8 to original file to create thumbs from.
* @return void
*/
- function add_thumb($file)
+ function addThumbs($file)
{
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index a38b034747b..3a14593f9f3 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -257,7 +257,7 @@ class FileUpload
}
/**
- * Create thumbs
+ * Create thumbs of a file uploaded. Only the "mini" thumb is generated.
*
* @param string $file_name Filename
* @param string $options is array('max_width', 'max_height')
@@ -277,9 +277,8 @@ class FileUpload
return false;
}
- $res=vignette($file_path,$maxwidthmini,$maxheightmini,'_mini');
+ $res=vignette($file_path,$maxwidthmini,$maxheightmini,'_mini'); // We don't use ->addThumbs here because there is no object and we don't need all thumbs, only the "mini".
- //return $success;
if (preg_match('/error/i',$res)) return false;
return true;
}
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index c6256475592..7d8ac5f1750 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -1486,7 +1486,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
}
if (image_format_supported($destpath) == 1)
{
- // Create small thumbs for image (Ratio is near 16/9)
+ // Create thumbs
+ // We can't use $object->addThumbs here because there is no $object known
+
// Used on logon for example
$imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php
index 20c35bef497..8a22e159cc7 100644
--- a/htdocs/core/photos_resize.php
+++ b/htdocs/core/photos_resize.php
@@ -124,7 +124,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
if ($result == $fullpath)
{
- $object->add_thumb($fullpath);
+ $object->addThumbs($fullpath);
if ($backtourl)
{
@@ -153,7 +153,7 @@ if ($action == 'confirm_crop')
if ($result == $fullpath)
{
- $object->add_thumb($fullpath);
+ $object->addThumbs($fullpath);
if ($backtourl)
{
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index a538e4543ee..e9af15bb27e 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -3507,8 +3507,8 @@ class Product extends CommonObject
if (file_exists(dol_osencode($originImage)))
{
- // Cree fichier en taille vignette
- $this->add_thumb($originImage);
+ // Create thumbs
+ $this->addThumbs($originImage);
}
}
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 26fcb8ac478..866e53bcd6b 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -481,13 +481,8 @@ if (empty($reshook))
}
else
{
- // Create small thumbs for company (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
-
- // Create mini thumbs for company (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
+ // Create thumbs
+ $object->addThumbs($newfile);
}
}
}
@@ -859,13 +854,8 @@ else
}
else
{
- // Create small thumbs for company (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
-
- // Create mini thumbs for company (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
+ // Create thumbs
+ $object->addThumbs($newfile);
}
}
}
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index 174014579e1..acfe1c85cd7 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -453,13 +453,8 @@ if (empty($reshook)) {
if (!$result > 0) {
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
} else {
- // Create small thumbs for company (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
-
- // Create mini thumbs for company (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
+ // Create thumbs
+ $object->addThumbs($newfile);
}
} else {
$error ++;