Jump to content

How can I move img directory from default location?


rbalva01

Recommended Posts

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

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

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

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

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 by bellini13 (see edit history)
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...