Fix: missing images files filter

This commit is contained in:
Regis Houssin 2012-07-03 21:07:54 +02:00
parent a13bf2b93f
commit 5c2d8656cc

View File

@ -2632,7 +2632,7 @@ class Product extends CommonObject
if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory
if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$dir.$file)) if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file))
{ {
$nbphoto++; $nbphoto++;
$photo = $file; $photo = $file;
@ -2641,8 +2641,8 @@ class Product extends CommonObject
if ($size == 1) { // Format vignette if ($size == 1) { // Format vignette
// On determine nom du fichier vignette // On determine nom du fichier vignette
$photo_vignette=''; $photo_vignette='';
if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$photo,$regs)) { if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) {
$photo_vignette=preg_replace('/'.$regs[0].'/i','',$photo)."_small".$regs[0]; $photo_vignette=preg_replace('/'.$regs[0].'/i', '', $photo)."_small".$regs[0];
if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette='';
} }
@ -2677,7 +2677,7 @@ class Product extends CommonObject
{ {
$return.= '<br>'; $return.= '<br>';
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
if ($photo_vignette && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) if ($photo_vignette && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight))
{ {
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>'; $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>';
} }
@ -2764,16 +2764,16 @@ class Product extends CommonObject
while (($file = readdir($handle)) != false) while (($file = readdir($handle)) != false)
{ {
if (! utf8_check($file)) $file=utf8_encode($file); // readdir returns ISO if (! utf8_check($file)) $file=utf8_encode($file); // readdir returns ISO
if (dol_is_file($dir.$file)) if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file))
{ {
$nbphoto++; $nbphoto++;
// On determine nom du fichier vignette // On determine nom du fichier vignette
$photo=$file; $photo=$file;
$photo_vignette=''; $photo_vignette='';
if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$photo,$regs)) if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs))
{ {
$photo_vignette=preg_replace('/'.$regs[0].'/i','',$photo).'_small'.$regs[0]; $photo_vignette=preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0];
} }
$dirthumb = $dir.'thumbs/'; $dirthumb = $dir.'thumbs/';