From 0f358eea49456451b9fb63206a5bef26d6560715 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Nov 2015 01:56:56 +0100 Subject: [PATCH] Fix path definition of thumbs with the new function --- htdocs/core/lib/functions.lib.php | 10 +++++----- htdocs/core/lib/images.lib.php | 4 +++- htdocs/product/document.php | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 727dd9d8a9e..be0523958bd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5225,17 +5225,17 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) /** * Return the filename of file to get the thumbs * - * @param string $file Original filename + * @param string $file Original filename (full or relative path) * @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini') - * @param string $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image. - * @return string New file name + * @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image. + * @return string New file name (full or relative path, including the thumbs/) */ function getImageFileNameForSize($file, $extName, $extImgTarget='') { $dirName = dirname($file); if ($dirName == '.') $dirName=''; - $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // We remove extension, whatever is its case $fileName = basename($fileName); if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':''); @@ -5249,5 +5249,5 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') $subdir=''; if ($extName) $subdir = 'thumbs/'; - return $dirName.$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb + return ($dirName?$dirName.'/':'').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb } diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index e61dc22eeb0..20a58d7021c 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -512,7 +512,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse $fileName = basename($fileName); - $imgThumbName = $dirthumb.'/'.getImageFileNameForSize($file, $extName, $extImgTarget); // Chemin complet du fichier de la vignette + //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file + $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file + // Check if permission are ok //$fp = fopen($imgThumbName, "w"); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 3d5f40b768c..baf736b47e5 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -70,8 +70,8 @@ if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); + if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs {