Contributions
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
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
This makes a few more minor changes and also adds some screenshots to the package.
It takes into account several posts on the forum about the contrib, which will make it work a little better.
remember to check the help forum for this contrib:
http://forums.oscommerce.com/index.php?showtopic=264751
Thanks to nikita for pointing out I'd left out coding to allow for multiple sub categories such as:
images/products/men/hats/summer
This latest update takes that into consideration.
If you've already installed this contrib and just want the update check this post: http://forums.oscommerce.com/index.php?s=&showtopic=264751&view=findpost&p=1085443
Okay.. sorry guys. Just found a slight error in my code due to some changes I had to make speciffically for my site.
THIS update only changes these small errors.
Also here's the link to the officcial help forum for this contrib:
http://forums.oscommerce.com/index.php?showtopic=264751
An update of the previous. I realised there was a large error in verxion 1.1 which has been removed.
I've also changed the layout of the install file into an html file to make it easier to read.
Apart from that no changes, so if you're using v1.1 successfully there is no need to update.
This is an update of the previous contrib.
It allows a much easier way of editing the directories and now allows for setting seperate directories for product images.
It displays them in a products folder, then seperates them by category and even sub-category.
Should be quite easy to install...
just make sure you create the folders first!
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.
Note: Contributions are used at own risk.