From 7deb94618c41bcd249ba862ea6dbef0359e63b98 Mon Sep 17 00:00:00 2001 From: dMetzger Date: Tue, 25 Sep 2012 08:58:29 +0000 Subject: [PATCH] // Added images other than products to the new format --- .../upgrade/php/p15018_change_image_types.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/install-dev/upgrade/php/p15018_change_image_types.php b/install-dev/upgrade/php/p15018_change_image_types.php index 82a5c4e82..879abec3b 100644 --- a/install-dev/upgrade/php/p15018_change_image_types.php +++ b/install-dev/upgrade/php/p15018_change_image_types.php @@ -83,6 +83,26 @@ function p15018_change_image_types() rename(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'p'.DIRECTORY_SEPARATOR.$folder.$row['id_image'].'-'.$old_type.'.jpg', _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'p'.DIRECTORY_SEPARATOR.$folder.$row['id_image'].'-'.$new_type.'.jpg'); } + + // Then the other entities (if there is less than 500 products, that should not be a problem) + $directories = array('c', 'm', 's', 'scenes', 'scenes'.DIRECTORY_SEPARATOR.'thumbs', 'st'); + foreach ($directories as $directory) + foreach (scandir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.$directory) as $file) + { + if (!preg_match('/^[0-9]+\-[a-z_-]\.jpg$/i', $file)) + continue; + foreach ($replace_types as $type => $type_array) + foreach ($type_array as $old_type => $new_type) + if (preg_match('/^([0-9]+)\-'.$old_type.'\.jpg$/i', $file, $matches)) + { + if ($option) + copy(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.$directory.DIRECTORY_SEPARATOR.$matches[1].'-'.$old_type.'.jpg', + _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.$directory.DIRECTORY_SEPARATOR.$matches[1].'-'.$new_type.'.jpg'); + else + rename(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.$directory.DIRECTORY_SEPARATOR.$matches[1].'-'.$old_type.'.jpg', + _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.$directory.DIRECTORY_SEPARATOR.$matches[1].'-'.$new_type.'.jpg'); + } + } } return true;