New Zenner
- Join Date:
- Mar 2006
- Posts:
- 22
- Plugin Contributions:
- 0
Inefficient way to display multiple images in additional_images.php
Technically , this is not a bug, but rather a very inefficient way to find additional images for an image.
This problem has been around since 1.3.x , and I checked that it is still in 1.5.x
In includes/modules/additional_images.php
From Line 43,
you are going through the entire directory to find matching image files that has a form of
$products_image_base[num].$products_image_extension
But if there are thousands of file in the directory, that will really become extremely inefficient.
I suggest maybe its better to assume that we won't skip the additional image number and only search
the additional in a sequential way up till we don't find the next number.
e.g.
image base is = "test_"
we will search the directory from test_1 and stop when test_n doesnt exist.
as a sample, here is some sample code
$done = false;
$count=1;
while (!$done) {
$filename = $products_image_directory . $products_image_base . $count . $products_image_extension;
//echo "$f = " . $filename . "\n";
if (file_exists($filename)) {
$images_array[] = $products_image_base.$count.$products_image_extension;
$count++;
}
else
$done = true;
}