From 8ad46b5d5f966e8ba5065f36234ed3d8b9998b8a Mon Sep 17 00:00:00 2001 From: Lev Andronov Date: Sun, 16 Jul 2023 15:01:01 +0300 Subject: [PATCH] Update func.common.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit давайте сделаем по-человечески, чтоб при загрузке фотографий они сортировались по имени, а не в случайном порядке (или в порядке последнего изменения). --- functions/func.common.php | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/functions/func.common.php b/functions/func.common.php index 333dd49..8753842 100755 --- a/functions/func.common.php +++ b/functions/func.common.php @@ -613,23 +613,19 @@ function image_multi_import($path) $files = array(); $thumbs = array(); - if ($handle = opendir($dir)) - { - while (false !== ($file = readdir($handle))) - { - $nameParts = explode('.', $file); - $ext = strtolower(end($nameParts)); - - if ($file != "." && $file != ".." && in_array($ext, $images_ext)) - { - if (! is_dir($dir . "/" . $file)) - { - $files[] = $file; - $thumbs[] = make_thumbnail(array('link' => $dir_abs . $file, 'size' => 't128x128')); - } - } - } - closedir($handle); + $img_files = scandir($dir); + foreach ($img_files as $file) { + $nameParts = explode('.', $file); + $ext = strtolower(end($nameParts)); + + if ($file != "." && $file != ".." && in_array($ext, $images_ext)) + { + if (! is_dir($dir . "/" . $file)) + { + $files[] = $file; + $thumbs[] = make_thumbnail(array('link' => $dir_abs . $file, 'size' => 'f128x128')); + } + } } //$return = array( @@ -1418,4 +1414,4 @@ function ($matches) { return $fixed; } } -?> \ No newline at end of file +?>