Assuming you only want to use medium additional images, this will build the additional image list from the medium folder. You will not need additional image files in the thumbnail folder; the image names will need the _MED suffix.
The code is spread out more than DrByte's example. Find
PHP Code:
$products_image_directory = str_replace($products_image, '', substr($products_image, strrpos($products_image, '/')));
if ($products_image_directory != '') {
$products_image_directory = DIR_WS_IMAGES . str_replace($products_image_directory, '', $products_image) . "/";
} else {
$products_image_directory = DIR_WS_IMAGES;
}
// Check for additional matching images
$file_extension = $products_image_extension;
$products_image_match_array = array();
if ($dir = @dir($products_image_directory)) {
while ($file = $dir->read()) {
if (!is_dir($products_image_directory . $file)) {
if (substr($file, strrpos($file, '.')) == $file_extension) {
// if(preg_match("/" . $products_image_match . "/i", $file) == '1') {
if(preg_match("/" . $products_image_base . "/i", $file) == '1') {
if ($file != $products_image) {
if ($products_image_base . str_replace($products_image_base, '', $file) == $file) {
// echo 'I AM A MATCH ' . $file . '<br>';
$images_array[] = $file;
} else {
// echo 'I AM NOT A MATCH ' . $file . '<br>';
}
and replace with
PHP Code:
$products_image_directory = str_replace($products_image, '', substr($products_image, strrpos($products_image, '/')));
if ($products_image_directory != '') { //med add: product is in a subdir - insert medium/ into dir path
$products_image_directory = DIR_WS_IMAGES . str_replace($products_image_directory, '', $products_image) . "/";
$products_image_directory_medium = DIR_WS_IMAGES . 'medium/' . str_replace($products_image_directory, '', $products_image) . "/";
} else { //med add: product is in /images/ - insert medium/ into dir path
$products_image_directory = DIR_WS_IMAGES;
$products_image_directory_medium = DIR_WS_IMAGES . 'medium/';
}
// Check for additional matching images
$file_extension = $products_image_extension;
$products_image_match_array = array();
if ($dir = @dir($products_image_directory_medium)) { //med add: if med is valid dir
while ($file = $dir->read()) {
if (!is_dir($products_image_directory_medium . $file)) { //med add: if item being read is file, not subdir
if (substr($file, strrpos($file, '.')) == $file_extension) {
// if(preg_match("/" . $products_image_match . "/i", $file) == '1') {
if(preg_match("/" . $products_image_base . "/i", $file) == '1') {
if ($file != (str_replace($products_image_extension, '', $products_image) . IMAGE_SUFFIX_MEDIUM . $products_image_extension)) { //med add: check against main med img, not main thumb
if ($products_image_base . str_replace($products_image_base, '', $file) == $file) {
if (substr($file, strrpos($file, IMAGE_SUFFIX_MEDIUM)) == IMAGE_SUFFIX_MEDIUM . $file_extension) { //med add: if filename ends in _MED
// echo 'I AM A MATCH ' . $file . '<br>';
$images_array[] = $file;
} else {
// echo 'I AM NOT A MATCH ' . $file . '<br>';
} //med add: substr
}
Find
PHP Code:
$base_image = $products_image_directory . $file;
$thumb_slashes = zen_image($base_image, addslashes($products_name), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
$thumb_regular = zen_image($base_image, $products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
and replace with
PHP Code:
$base_image = $products_image_directory_medium . $file; //med add: use med dir
$thumb_slashes = zen_image($base_image, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT); //med add: medium w & h
$thumb_regular = zen_image($base_image, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT); //med add: medium w & h
Note: this is not yet tested. Please let me know how it works.