diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php
index 97ceb63be4b..452fed9b8ac 100644
--- a/htdocs/lib/functions.inc.php
+++ b/htdocs/lib/functions.inc.php
@@ -2955,6 +2955,11 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120){
// Si le fichier passé en paramètre n'existe pas
return 'Le fichier '.$file.' n\'a pas été trouvé sur le serveur.';
}
+ elseif(!eregi('(\.jpg|\.png)$',$files['name']))
+ {
+ // Todo: Ajouter création vignette pour les autres formats d'images
+ return 'Le fichier '.$file.' n\'ai pas géré pour le moment.';
+ }
elseif(empty($file)){
// Si le fichier n'a pas été indiqué
return 'Nom du fichier non renseigné.';
@@ -2982,6 +2987,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120){
dolibarr_syslog("Product Create $dirthumb");
create_exdir($dirthumb);
}
+
// Initialisation des variables selon l'extension de l'image
switch($infoImg[2]){
diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index a240b2ea2e9..ed2444faeda 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -2123,11 +2123,11 @@ class Product
/**
* \brief Déplace fichier uploadé sous le nom $files dans le répertoire sdir
* \param sdir Répertoire destination finale
- * \param $files Nom du fichier uploadé
+ * \param $file Nom du fichier uploadé
* \param maxWidth Largeur maximum que dois faire la miniature (160 par défaut)
* \param maxHeight Hauteur maximum que dois faire la miniature (120 par défaut)
*/
- function add_photo($sdir, $files, $maxWidth = 160, $maxHeight = 120)
+ function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
{
$dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/";
$dir .= "photos/";
@@ -2140,13 +2140,12 @@ class Product
if (file_exists($dir))
{
- $originImage = $dir . $files['name'];
+ $originImage = $dir . $file['name'];
// Crée fichier en taille origine
- doliMoveFileUpload($files['tmp_name'], $originImage);
-
- // Todo: Ajouter création vignette pour les autres formats d'images
- if (file_exists($originImage) && eregi('(\.jpg|\.png)$',$files['name']))
+ doliMoveFileUpload($file['tmp_name'], $originImage);
+
+ if (file_exists($originImage))
{
// Crée fichier en taille vignette
$this->add_thumb($originImage,$maxWidth,$maxHeight);
@@ -2157,13 +2156,16 @@ class Product
/**
* \brief Génère la vignette
* \param sdir Répertoire destination finale
- * \param file Nom du fichier d'origine
+ * \param file Chemin du fichier d'origine
* \param maxWidth Largeur maximum que dois faire la miniature (160 par défaut)
* \param maxHeight Hauteur maximum que dois faire la miniature (120 par défaut)
*/
function add_thumb($file, $maxWidth = 160, $maxHeight = 120)
{
- vignette($file,$maxWidth,$maxHeight);
+ if (file_exists($file))
+ {
+ vignette($file,$maxWidth,$maxHeight);
+ }
}
/**
diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php
index ee0fc926918..946e0428470 100644
--- a/htdocs/product/photos.php
+++ b/htdocs/product/photos.php
@@ -203,7 +203,7 @@ if ($_GET["id"] || $_GET["ref"])
print '
'.$langs->trans("File").': '.dolibarr_trunc($viewfilename,16);
print '
';
// On propose la génération de la vignette si elle n'existe pas
- if (!$obj['photo_vignette'])
+ if (!$obj['photo_vignette'] && eregi('(\.jpg|\.png)$',$obj['photo']))
{
print ''.img_refresh($langs->trans('RegenerateThumb')).' ';
}