Contributions

Images (Category Index)
Search: 

change default image directories

This allows the image directories for manufacturer and category images to be changed.
This helps to organise your files and makes it easier to track your images.

This mod is very simple! only two lines to change for each file. This mod only effects two files, but could easily be changed to modify different images if needed.

Expand All / Collapse All

bug fix 16 Jan 2008

this:
// copy image only if modified
$cid = explode('_', $cPath);
foreach($cid as $key => $value){
$cdat = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id = '" . $value . "' && language_id = '1'");
$cat = tep_db_fetch_array($cdat);
$categoryfile .= $cat[categories_name] . "/";
$_SESSION['categoryfile'] = $categoryfile;
}

$products_image = new upload('products_image');
$products_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile);
if ($products_image->parse() && $products_image->save()) {
$products_image_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $products_image->filename;
} else {
-------------------------------------------------
replace with:

// copy image only if modified
$cid = explode('_', $cPath);
foreach($cid as $key => $value){
$cdat = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id = '" . $value . "' && language_id = '1'");
$cat = tep_db_fetch_array($cdat);if ($cat[categories_name] == !null){
$categoryfile .= $cat[categories_name] . "/";}
if (file_exists(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile)==false)
{$str = DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile ;
mk_dir($str);
};
$_SESSION['categoryfile'] = $categoryfile;
}

$products_image = new upload('products_image');
$products_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile);
if ($products_image->parse() && $products_image->save()) {
$products_image_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $products_image->filename;
} else {


/////////////////////////////////////////////////////////////
and this:
// check if the catalog image directory exists
if (is_dir(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile)) {
if (!is_writeable(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
} else {
$messageStack->add(ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
unset($_SESSION['categoryfile']);
}
------------------------------------------------
replace with:

if (is_dir(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile)) {
if (!is_writeable(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
} else {
$messageStack->add(ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
}
function mk_dir($str, $mode=0777) {
if(!(is_dir($str) || @mkdir($str, $mode))) {
mk_dir(dirname($str));
mk_dir($str);
}
}
unset($_SESSION['categoryfile']);



////////////////////////////////////////////////////////
make these changes, then the categories directoires will be aoto build in products directories and products pics will be into their categoies directories. that's easy to manager all products pisc !
thanks,
if have any problem, content me with simomchen41@gmail.com

change default image directories v1.4 13 Jun 2007
change default image directories v1.3 3 Jun 2007
change default image directories v1.2(update) 2 Jun 2007
change default image directories v1.2 31 May 2007
change default image directories v1.1 8 May 2007
change default image directories 7 May 2007

Note: Contributions are used at own risk.