Fix path definition of thumbs with the new function

This commit is contained in:
Laurent Destailleur 2015-11-06 01:56:56 +01:00
parent 2dc644da30
commit 0f358eea49
3 changed files with 10 additions and 8 deletions

View File

@ -5225,17 +5225,17 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
/** /**
* Return the filename of file to get the thumbs * 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 $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. * @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image.
* @return string New file name * @return string New file name (full or relative path, including the thumbs/)
*/ */
function getImageFileNameForSize($file, $extName, $extImgTarget='') function getImageFileNameForSize($file, $extName, $extImgTarget='')
{ {
$dirName = dirname($file); $dirName = dirname($file);
if ($dirName == '.') $dirName=''; 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); $fileName = basename($fileName);
if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':''); if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':'');
@ -5249,5 +5249,5 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
$subdir=''; $subdir='';
if ($extName) $subdir = 'thumbs/'; 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
} }

View File

@ -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 = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse
$fileName = basename($fileName); $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 // Check if permission are ok
//$fp = fopen($imgThumbName, "w"); //$fp = fopen($imgThumbName, "w");

View File

@ -70,8 +70,8 @@ if ($id > 0 || ! empty($ref))
{ {
$result = $object->fetch($id, $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); 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, 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, 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 if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
{ {