Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Image Path MOD for 4.1.x

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #21  
Old 05-27-2008, 02:40 PM
 
sparker2 sparker2 is offline
 

eXpert
  
Join Date: Feb 2007
Posts: 290
 

Default Re: Image Path MOD for 4.1.x

Now it adds the images but it puts them right back in the images/T folder, and it looks like it will only adds the thumbnail and then create the product image form that and give it a name adding 01 to it or something to that affect Even after I delete this folder it will create it again.
__________________
Shareen
sparker2@cox.net
http://www.stitches4u.com
X-Cart Version 4.5.0 with Smart Template vs 4.4.x
Reply With Quote
  #22  
Old 05-27-2008, 02:54 PM
 
sparker2 sparker2 is offline
 

eXpert
  
Join Date: Feb 2007
Posts: 290
 

Default Re: Image Path MOD for 4.1.x

Code does not work with my version looks like ):
__________________
Shareen
sparker2@cox.net
http://www.stitches4u.com
X-Cart Version 4.5.0 with Smart Template vs 4.4.x
Reply With Quote
  #23  
Old 05-27-2008, 03:46 PM
 
robertswww robertswww is offline
 

X-Adept
  
Join Date: Jul 2003
Posts: 586
 

Default Re: Image Path MOD for 4.1.x

I plan to upgrade to 4.1.10 sometime in the next week. I'll post back if there are any changes to the code. Since 4.1.10 is mostly bug fixes, I expect this same code should work just fine.

Double-Check that you did both Step 1 and Step 2 in Post #1.

Remember... this mod is for adding images to New Products or you can Modify Existing products via the Admin interface, but you need to make sure you are adding the images, directly from your files/image(s) folders on your server (not your local drive).

If you don't have a product image, X-Cart will default and use the thumbnail on the detailed product page, the same as it did in X-Cart 4.0.x and previous versions. If you want a separate product image, you can add that on the individual Add Product and Modify Product pages. Also, this mod supports the X-Cart Detailed Images Module.

Robert
__________________
X-cart 4.1.10
Reply With Quote
  #24  
Old 05-27-2008, 06:49 PM
 
sparker2 sparker2 is offline
 

eXpert
  
Join Date: Feb 2007
Posts: 290
 

Default Re: Image Path MOD for 4.1.x

Robert i got this to work but when I look at the Table in the database: xcart_images_P and Table: xcart_images_T it shows the image path as ./images/P/anml-buy-all_org.jpg and ./images/T/anml-buy-all_org.jpg instead of just ./files/images/anml-buy-all_org.jpg

Just thought i would give you an update on my progress
__________________
Shareen
sparker2@cox.net
http://www.stitches4u.com
X-Cart Version 4.5.0 with Smart Template vs 4.4.x
Reply With Quote
  #25  
Old 05-29-2008, 05:57 AM
 
robertswww robertswww is offline
 

X-Adept
  
Join Date: Jul 2003
Posts: 586
 

Default Re: Image Path MOD for 4.1.x

Hi Shareen,

Thanks for the update, here's a couple more things to check...

1. Make sure that you have your Admin --> Images Location set to use the FileSystem for storing images and not the Database.

2. When you look at the Database xcart_images_T, etc. folders, and you still see the image path pointing to the /images/T etc. folders... maybe this is just for your existing images. In other words, this Mod only puts new product images you add or modify into the files/images/sub-folders.

You can check if a new product image you added is in the correct location, by Browsing the xcart_images_T folder and click the >> (arrows) to jump to the end of the table where the newest product images have been added. Look at those image_paths. If they are correct, the mod is working fine for you, but you will then need to update all your existing image file paths either by manually editing them or via an automated script.

Robert
__________________
X-cart 4.1.10
Reply With Quote
  #26  
Old 07-07-2008, 03:27 PM
 
robertswww robertswww is offline
 

X-Adept
  
Join Date: Jul 2003
Posts: 586
 

Default Re: Image Path MOD for 4.1.x

Image Path MOD for 4.1.10 with Security Fix from July 2, 2008

First, backup of your store files and DB. Also work on copies of the 2 files that are being modified, so you can change back quickly, if need be.

Next, make sure your Images Location is set to use the File System (FS).

MOD 01
File: include/func/func.backoffice.php (Line 49) - NOTE: This MOD now incorporates the 4.1.10 Security Fix Code

NOTE: The proper image file path (the part before the /files/ directory) can be found on the Summary page of your X-Cart back-end. Look under the Component column for your X-Cart directory, and enter the value you see in the Status column.

CODE Was:
Code:
# # This function determine the files location for current user # function func_get_files_location ($uname = "", $usertype = "") { global $login, $current_area, $active_modules, $single_mode, $files_dir_name; global $user_account; if ($uname === "") $uname = $login; if ($usertype === "") $usertype = $user_account["usertype"]; if ($single_mode || $usertype == "A") return $files_dir_name; $wrong_catalog = true; if (preg_match("/([a-z0-9_-]+)/", $uname, $normalize_login)) { $files_dir = $files_dir_name.DIRECTORY_SEPARATOR.$normalize_login[1]; $wrong_catalog = ($normalize_login[1] != $uname); } if ($wrong_catalog) { global $smarty; $err_msg = func_get_langvar_by_name("msg_err_files_directory"); if (!$err_msg) $err_msg = "Your files directory does not exist. For more information please contact the store administrator."; $smarty->assign("top_message", array( "content" => $err_msg, "type" => "E" )); $files_dir = false; } return $files_dir; }

CODE Now:
Code:
# # This function determine the files location for current user # function func_get_files_location ($uname = "", $usertype = "") { global $login, $current_area, $active_modules, $single_mode, $files_dir_name; global $user_account; ### Custom MOD - Image directory file path - Comment out 2 lines below and hard-code image path to your files folder... if ($uname === "") $uname = $login; if ($usertype === "") $usertype = $user_account["usertype"]; if ($single_mode || $usertype == "A") ## return $files_dir_name; return "/home/yoursite/public_html/files/"; ### NOTE - Add this MOD line $wrong_catalog = true; if (preg_match("/([a-z0-9_-]+)/", $uname, $normalize_login)) { $files_dir = $files_dir_name.DIRECTORY_SEPARATOR.$normalize_login[1]; $wrong_catalog = ($normalize_login[1] != $uname); } if ($wrong_catalog) { global $smarty; $err_msg = func_get_langvar_by_name("msg_err_files_directory"); if (!$err_msg) $err_msg = "Your files directory does not exist. For more information please contact the store administrator."; $smarty->assign("top_message", array( "content" => $err_msg, "type" => "E" )); $files_dir = false; } ## return $files_dir; return "/home/yoursite/public_html/files/"; ### NOTE - Add this MOD line }


MOD 02:
File: include/func/func.image.php (Line 502) NOTE: This section of code has remained the same from 4.1.9 to 4.1.10

Part of: function func_prepare_image($file_upload_data, $type = 'T', $id = 0) {
# Prepare posted image for saving

CODE Was:
Code:
if ($config_data["location"] == "FS") { $prepared['image_path'] = ""; if (!is_url($file_path) || $config_data['save_url'] == 'Y') { $dest_file = func_image_dir($type); if (!zerolen($prepared['filename'])) { $dest_file .= "/".$prepared['filename']; } $prepared['image_path'] = func_store_image_fs($image_data, $type); if (zerolen($prepared['image_path'])) return false; $prepared['filename'] = basename($prepared['image_path']); $path = func_relative_path($prepared['image_path'], $xcart_dir); if ($path !== false) { $prepared['image_path'] = $path; } } else { $prepared['image_path'] = $file_path; } }


NOTE: All the code in MOD 2 below is commented out except for the final closing bracket, and this line: $prepared['image_path'] = $file_path;

CODE Now:
Code:
### Custom MOD - Comment out section below to prevent X-Cart from changing file name and saving to a lettered image subfolder, but keep $prepared line at end if ($config_data["location"] == "FS") { $prepared['image_path'] = ""; /* if (!is_url($file_path) || $config_data['save_url'] == 'Y') { $dest_file = func_image_dir($type); if (!zerolen($prepared['filename'])) { $dest_file .= "/".$prepared['filename']; } $prepared['image_path'] = func_store_image_fs($image_data, $type); if (zerolen($prepared['image_path'])) return false; $prepared['filename'] = basename($prepared['image_path']); $path = func_relative_path($prepared['image_path'], $xcart_dir); if ($path !== false) { $prepared['image_path'] = $path; } } else { */ $prepared['image_path'] = $file_path; ### } }


Robert
__________________
X-cart 4.1.10
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:39 AM.

   

 
X-Cart forums © 2001-2020