rbalva01 Posted August 11, 2015 Share Posted August 11, 2015 Hello, I have PrestaShop 1.6.0.14 installed on a XAMPP server, for this instance I need to move the C:/xampp/htdocs/prestashop/img directory from this location to C:/StorageFolder/ImageStorageFolder/img. So far, I've tried to move the folder directly via Windows Explorer and changed the values of _PS_IMG_, _PS_IMG_DIR_ and _PS_CORE_IMG_DIR_ in defines.inc.php and defines_uri.inc.php, but PrestaShop won't load the image files from the new directory, it will try to fetch the images from the original folder. What am I doing wrong? Is there a way to change the img directory to another location to begin with? Thanks in advance. Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted August 11, 2015 Share Posted August 11, 2015 Hello, I have PrestaShop 1.6.0.14 installed on a XAMPP server, for this instance I need to move the C:/xampp/htdocs/prestashop/img directory from this location to C:/StorageFolder/ImageStorageFolder/img. So far, I've tried to move the folder directly via Windows Explorer and changed the values of _PS_IMG_, _PS_IMG_DIR_ and _PS_CORE_IMG_DIR_ in defines.inc.php and defines_uri.inc.php, but PrestaShop won't load the image files from the new directory, it will try to fetch the images from the original folder. What am I doing wrong? Is there a way to change the img directory to another location to begin with? Thanks in advance. Hello why you need move the image C:/StorageFolder/ImageStorageFolder/img. ? C:/xampp/htdocs/prestashop/ this path is your root path in prestashop if you move the img folder then you can not use prestashop variables.like as _PS_IMG_,PS_IMG_DIR_ . thanks. Link to comment Share on other sites More sharing options...
rbalva01 Posted August 11, 2015 Author Share Posted August 11, 2015 If I can't just move the directory like that, then how? It is my client's request, they need to access the img directory from another application in that specific location. Link to comment Share on other sites More sharing options...
rbalva01 Posted August 11, 2015 Author Share Posted August 11, 2015 For the record, with the modified configurations I've managed to make PrestaShop able to write the image files into C:/StorageFolder/ImageStorageFolder/img, but is still NOT able to read from that location. Link to comment Share on other sites More sharing options...
musicmaster Posted August 12, 2015 Share Posted August 12, 2015 Reading is done from the theme files like product.tpl and product-list.tpl. Did you look how it is coded there? Maybe they hardcoded "\img". Link to comment Share on other sites More sharing options...
bellini13 Posted August 12, 2015 Share Posted August 12, 2015 Image URL's are handled by Link::getImageLink function. This function uses the global variable _PS_PROD_IMG_DIR_, which is built from _PS_IMG_DIR_ So why don't you show us what you changed in defines.inc.php also, confirm that you cleared smarty cache after making this change Link to comment Share on other sites More sharing options...
rbalva01 Posted August 12, 2015 Author Share Posted August 12, 2015 Image URL's are handled by Link::getImageLink function. This function uses the global variable _PS_PROD_IMG_DIR_, which is built from _PS_IMG_DIR_ So why don't you show us what you changed in defines.inc.php also, confirm that you cleared smarty cache after making this change I've changed this lines in defines.inc.php and defines_uri.inc.php: defines.inc.php define('_PS_IMG_DIR_', 'C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/'); if (!defined('_PS_HOST_MODE_')) define('_PS_CORE_IMG_DIR_', 'C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/'); else define('_PS_CORE_IMG_DIR_', 'C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/'); /* define('_PS_IMG_DIR_', _PS_ROOT_DIR_.'/img/'); if (!defined('_PS_HOST_MODE_')) define('_PS_CORE_IMG_DIR_', _PS_CORE_DIR_.'/img/'); else define('_PS_CORE_IMG_DIR_', _PS_ROOT_DIR_.'/img/'); */ defines_uri.inc.php /* Image URLs */ //define('_PS_IMG_', __PS_BASE_URI__.'img/'); define('_PS_IMG_', 'C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/'); At the time I did not delete the smarty cache, I have now deleted it following the steps in this tutorial: http://www.templatemonster.com/help/prestashop-1-6-x-how-to-clear-smarty-cache.html But I'm still not able to see images in my product catalog or front office, are those edited values the right ones? Link to comment Share on other sites More sharing options...
bellini13 Posted August 12, 2015 Share Posted August 12, 2015 (edited) So there are 2 things you need to consider, and I believe you have only considered one of these things 1) When an image is uploaded to the store, where does Prestashop store these images. 2) When an image is viewed in a browser (either front office or back office), where is the image served from So, the first thing you need to confirm is that the folder where you want to store your images, is that available to the web server you are using? C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/ If so, what is the URL to reach this folder? Edited August 12, 2015 by bellini13 (see edit history) Link to comment Share on other sites More sharing options...
rbalva01 Posted August 12, 2015 Author Share Posted August 12, 2015 That's precisely what I thought after tweaking the Link.php class file (where the getImageLink method is defined), as I said before, there was no problem with the image loading after editing the constant values for _PS_IMG_DIR_, etc. I didn't realize, though, that I was trying to access that location as a filesystem dir, not as a URL, which led to a "Not allowed to load local resource" console alert in Chrome. Those images are going to be accessed through another web application (which is why my clients wanted to store all images in C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/ in the first place) and, therefore, it'll provide a URL as constant value instead of a filesystem directory location. I tested with links to some wikimedia commons images hardcoded into getImageLink, getMediaLink and getCatImageLink and images loaded alright, so I should not get any problems when I use the webapp URL in those methods. TL;DR: URLs good, filesystem location bad. So, yeah, I figured how the "load images" part worked, but not how the browser requested sources. Thanks for your answers, they led me into the right direction Link to comment Share on other sites More sharing options...
Bill Dalton Posted August 13, 2015 Share Posted August 13, 2015 You just need to make the file location a Virtual directory on the web server and then give it an alias name, for example "img". That will take care of the HTTP requests. http://el.web.id/how-to-add-virtual-directory-alias-on-apache-xampp-165 Link to comment Share on other sites More sharing options...
musicmaster Posted August 13, 2015 Share Posted August 13, 2015 TL;DR: URLs good, filesystem location bad. I don't know where your shop is. But what about relative links? Like "../../img". Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now