Fix pb with svg images

This commit is contained in:
Laurent Destailleur 2019-12-19 19:09:56 +01:00
parent 44978db027
commit 03649ea2c8
3 changed files with 13 additions and 8 deletions

View File

@ -33,7 +33,7 @@ $quality = 80;
* Return if a filename is file name of a supported image format * Return if a filename is file name of a supported image format
* *
* @param string $file Filename * @param string $file Filename
* @return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported by this PHP * @return int -1=Not image filename, 0=Image filename but format not supported for conversion by PHP, 1=Image filename with format supported by this PHP
*/ */
function image_format_supported($file) function image_format_supported($file)
{ {
@ -57,12 +57,12 @@ function image_format_supported($file)
{ {
if (!function_exists($imgfonction)) if (!function_exists($imgfonction))
{ {
// Fonctions de conversion non presente dans ce PHP // Fonctions of conversion not available in this PHP
return 0; return 0;
} }
} }
// Filename is a format image and supported by this PHP // Filename is a format image and supported for conversion by this PHP
return 1; return 1;
} }

View File

@ -4835,8 +4835,10 @@ class Product extends CommonObject
global $conf; global $conf;
$dir = $sdir; $dir = $sdir;
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $dir .= '/'.get_exdir($this->id, 2, 0, 0, $this, 'product').$this->id."/photos/"; if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
} else { $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref).'/'; $dir .= '/'.get_exdir($this->id, 2, 0, 0, $this, 'product').$this->id."/photos/";
} else {
$dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref).'/';
} }
$nbphoto = 0; $nbphoto = 0;
@ -4847,9 +4849,11 @@ class Product extends CommonObject
if (is_resource($handle)) { if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (!utf8_check($file)) { $file = utf8_encode($file); // To be sure data is stored in UTF8 in memory if (!utf8_check($file)) {
$file = utf8_encode($file); // To be sure data is stored in UTF8 in memory
} }
if (dol_is_file($dir.$file) && image_format_supported($file) > 0) { return true; if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) {
return true;
} }
} }
} }

View File

@ -1446,7 +1446,7 @@ div.heightref {
min-height: 80px; min-height: 80px;
} }
div.divphotoref { div.divphotoref {
padding-<?php echo $right; ?>: 20px; padding-<?php echo $right; ?>: 10px;
} }
div.paginationref { div.paginationref {
padding-bottom: 10px; padding-bottom: 10px;
@ -3602,6 +3602,7 @@ label.radioprivate {
.photowithmargin { .photowithmargin {
margin-bottom: 2px; margin-bottom: 2px;
margin-top: 10px; margin-top: 10px;
margin-right: 10px;
} }
.photowithborder { .photowithborder {
border: 1px solid #f0f0f0; border: 1px solid #f0f0f0;