From 92c1022b8edce3508dc38ef7b18483df3a265d6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 May 2021 14:49:07 +0200 Subject: [PATCH] Fix duplicate in webp --- htdocs/core/tpl/filemanager.tpl.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index bf5a33c22fc..d8bbe0c7cc0 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -197,19 +197,23 @@ if ($action == 'convertimgwebp' && $permtoadd) { $regeximgext = getListOfPossibleImageExt(); - $filelist = dol_dir_list($imagefolder, "all", 0, $regeximgext); + $filelist = dol_dir_list($imagefolder, "files", 0, $regeximgext); + + $nbconverted = 0; foreach ($filelist as $filename) { $filepath = $filename['fullname']; if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) { if (image_format_supported($filepath) == 1) { - $filepathnoext = preg_replace("/\..*/", "", $filepath); + $filepathnoext = preg_replace("/\.[a-z0-9]+$/i", "", $filepath); if (! dol_is_file($filepathnoext.'.webp')) { // If file does not exists yet $result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp', 90); if (!dol_is_file($result)) { $error++; setEventMessages($result, null, 'errors'); + } else { + $nbconverted++; } } }