Fix thumbs generation
This commit is contained in:
parent
22045603b7
commit
77dd07c846
@ -1330,17 +1330,23 @@ class Categorie extends CommonObject
|
|||||||
* Build thumb
|
* Build thumb
|
||||||
*
|
*
|
||||||
* @param string $file Chemin du fichier d'origine
|
* @param string $file Chemin du fichier d'origine
|
||||||
* @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
|
|
||||||
* @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function add_thumb($file, $maxWidth = 160, $maxHeight = 120)
|
function add_thumb($file)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
|
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ...
|
||||||
|
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
vignette($file,$maxWidth,$maxHeight);
|
// Create small thumbs for company (Ratio is near 16/9)
|
||||||
|
// Used on logon for example
|
||||||
|
$imgThumbSmall = vignette($file, $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($file, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3100,11 +3100,9 @@ class Product extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param string $sdir Target directory
|
* @param string $sdir Target directory
|
||||||
* @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...)
|
* @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...)
|
||||||
* @param int $maxWidth Largeur maximum que dois faire la miniature (160 by defaut)
|
|
||||||
* @param int $maxHeight Hauteur maximum que dois faire la miniature (120 by defaut)
|
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
|
function add_photo($sdir, $file)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -3114,10 +3112,12 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
$dir = $sdir;
|
$dir = $sdir;
|
||||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos";
|
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos";
|
||||||
|
else $dir .= '/'.dol_sanitizeFileName($this->ref);
|
||||||
|
|
||||||
dol_mkdir($dir);
|
dol_mkdir($dir);
|
||||||
|
|
||||||
$dir_osencoded=$dir;
|
$dir_osencoded=$dir;
|
||||||
|
|
||||||
if (is_dir($dir_osencoded))
|
if (is_dir($dir_osencoded))
|
||||||
{
|
{
|
||||||
$originImage = $dir . '/' . $file['name'];
|
$originImage = $dir . '/' . $file['name'];
|
||||||
@ -3128,7 +3128,7 @@ class Product extends CommonObject
|
|||||||
if (file_exists(dol_osencode($originImage)))
|
if (file_exists(dol_osencode($originImage)))
|
||||||
{
|
{
|
||||||
// Cree fichier en taille vignette
|
// Cree fichier en taille vignette
|
||||||
$this->add_thumb($originImage,$maxWidth,$maxHeight);
|
$this->add_thumb($originImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3140,18 +3140,24 @@ class Product extends CommonObject
|
|||||||
* Build thumb
|
* Build thumb
|
||||||
*
|
*
|
||||||
* @param string $file Chemin du fichier d'origine
|
* @param string $file Chemin du fichier d'origine
|
||||||
* @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
|
|
||||||
* @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function add_thumb($file, $maxWidth = 160, $maxHeight = 120)
|
function add_thumb($file)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
|
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ...
|
||||||
|
|
||||||
$file_osencoded=dol_osencode($file);
|
$file_osencoded=dol_osencode($file);
|
||||||
if (file_exists($file_osencoded))
|
if (file_exists($file_osencoded))
|
||||||
{
|
{
|
||||||
vignette($file,$maxWidth,$maxHeight);
|
// Create small thumbs for company (Ratio is near 16/9)
|
||||||
|
// Used on logon for example
|
||||||
|
$imgThumbSmall = vignette($file, $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($file, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user