$product_images = array(); if ($product['p']['products_image'] != '') { $product_images[] = $product['p']['products_image']; } if ($product['p']['products_pure_image'] != '') { $product_images[] = $product['p']['products_pure_image']; } if ($product['pci']['products_clear_image'] != '') { $product_images[] = $product['pci']['products_clear_image']; } $extra_image = $product['pei']; foreach ($extra_image as $ei) { $product_images[] = $ei; } if (count($product_images) > 0) { $get_def_length = $class_pa->getDefault($pid); if ($product['categories_id'] == 29) { $length_for_code = '_' . number_format($get_def_length['products_length'] * 10, 0); } else { $length_for_code = '_' . number_format($get_def_length['products_length'], 0); if ($get_def_length['products_length'] == '0.00') { $length_for_code = ''; } } $img_counter = 0; foreach ($product_images as $pi) { $img_location = is_file($pi) ? $pi : DIR_WS_IMAGES . $pi; if (is_file($img_location)) { $img_counter++; $suffix = $img_counter == 1 ? '' : str_pad($img_counter - 1, 2, '_0', STR_PAD_LEFT); $new_filename = $product['p']['products_model'] . $length_for_code . $suffix . '.jpg';