Zen Cart Logo
Forums / Basic Configuration / Relative path to images

Relative path to images

Views: 2,097

Results 1 to 9 of 9
27 Dec 2012, 3:04 PM
#1
nohug4u avatar

nohug4u

New Zenner

Join Date:
Feb 2010
Posts:
16
Plugin Contributions:
0

Relative path to images

I’ve had a live site for a couple of years. For purposes of my question, the url to my live site is “mylivesite.com”. I need to make major changes to the site, so I recently set up a local copy on my laptop. For purposes of my question, the url to my local site is “mylocalsite.com”. Both sites are running on version 1.5.1.

When I initially set up my products on the live site, in the Products Description box I entered absolute addresses to my images. For example: src=”http://www.mylivesite.com/images/attributes_universal/usa-union.jpg”

The problem with absolute addresses is that I cannot make changes on my local site and test those changes before uploading them to my live site, so I want to convert all references from absolute to relative. And I need the reference to work on both my local and live sites.

I’ve been experimenting with just one of the products on my local site – in my admin I edited the Products Description box and changed the above path to: src="../images/attributes_universal/usa-union.jpg" When I preview the change in my admin, everything looks correct. When I access the product in any browser however, I get a rectangle where the image should be.

My understanding is that the paths that Zen Cart uses to access images (or other files for that matter) are defined in the configure.php files, so I’m thinking that may be where my problem is.

On my live site includes\configure.php includes the following definitions (these are the same as in the admin\includes\configure.php file):

Define(‘HTTP_SERVER’, ‘http://mylivesite.com’);
Define(‘HTTPS_SERVER’, ‘https://mylivesite.com’);
Define(‘ENABLE_SSL’, ‘true’);
Define(‘DIR_WS_CATALOG’, ‘/’);
Define(‘DIR_WS_IMAGES’, ‘images/’);
Define(‘DIR_FS_CATALOG’, ‘/home/accountname/public_html/’); (NOTE accountname is my accountname on my Host Gator server)

On my local site includes\configure.php has the following definitions:

Define(‘HTTP_SERVER’, ‘http://mylocalsite.com’);
Define(‘HTTPS_SERVER’, ‘https://mylocalsite.com’);
Define(‘ENABLE_SSL’, ‘false’);
Define(‘DIR_WS_CATALOG’, ‘/store/’);
Define(‘DIR_WS_IMAGES’, ‘images/’);
Define(‘DIR_FS_CATALOG’, ‘C:/xampp/htdocs/store/’);

I’m not sure if this is enough information to help diagnose my problem, or if any of the information I’ve included is relevant, but any help pointing me in the right direction is greatly appreciated.

27 Dec 2012, 3:37 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,102
Plugin Contributions:
56

Re: Relative path to images

While not in answer to your question, why are you referencing images in your products' descriptions? Why not let the built-in Zen Cart image handling do its thing?

27 Dec 2012, 5:25 PM
#3
nohug4u avatar

nohug4u

New Zenner

Join Date:
Feb 2010
Posts:
16
Plugin Contributions:
0

Re: Relative path to images

lat9:

While not in answer to your question, why are you referencing images in your products' descriptions? Why not let the built-in Zen Cart image handling do its thing?

I am using Image Handler 4 for the main product image, but in the Product Description I am including other images, for example a USA made logo, and an image of stock imprint colors available...

27 Dec 2012, 7:14 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,102
Plugin Contributions:
56

Re: Relative path to images

You could use ```
<img src="images/image_name.jpg” alt="image name" title="image title" />

27 Dec 2012, 8:59 PM
#5
nohug4u avatar

nohug4u

New Zenner

Join Date:
Feb 2010
Posts:
16
Plugin Contributions:
0

Re: Relative path to images

lat9:

You could use ```
<img src="images/image_name.jpg” alt="image name" title="image title" />


when i remove the ../ before images/, I don't even get an image when i preview the product in admin.
27 Dec 2012, 9:33 PM
#6
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Relative path to images

not in the admin, but you will in the shop. This is because the admin folder is one step above your shop (relatively)

27 Dec 2012, 10:45 PM
#7
nohug4u avatar

nohug4u

New Zenner

Join Date:
Feb 2010
Posts:
16
Plugin Contributions:
0

Re: Relative path to images

Design75:

not in the admin, but you will in the shop. This is because the admin folder is one step above your shop (relatively)

I should have been more clear in my comment. I'm not seeing the image in my admin or in my shop. Before I made the suggested change it was showing up in the admin but not the shop. After the change it doesn't show up in either one.

28 Dec 2012, 12:52 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,102
Plugin Contributions:
56

Re: Relative path to images

On a local v1.5.1 installation with the demo products installed, the change that I suggested results in only the alt-text displayed in the admin but has the image properly displayed in the storefront.

When you hit Ctrl+U to view the HMTL source for your storefront, what is your <base> set to? For that local installation, mine looks like:

<base href="http://localhost/zc151/" />

Are you using any redirects in your .htaccess file?

28 Dec 2012, 2:28 PM
#9
nohug4u avatar

nohug4u

New Zenner

Join Date:
Feb 2010
Posts:
16
Plugin Contributions:
0

Re: Relative path to images

When you hit Ctrl+U to view the HMTL source for your storefront, what is your <base> set to? For that local installation, mine looks like:

<base href="http://localhost/zc151/" /> ```

Mine looks like:

<base href="http://www.mylocalsite.com/store/" />

Are you using any redirects in your .htaccess file?

The only things in the /store/.htaccess file are CEON URI MAPPING REWRITE RULEs and some Google Analytics script.