Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2010
    Posts
    16
    Plugin Contributions
    0

    Default 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/att...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.

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,879
    Plugin Contributions
    96

    Default 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?

  3. #3
    Join Date
    Feb 2010
    Posts
    16
    Plugin Contributions
    0

    Default Re: Relative path to images

    Quote Originally Posted by lat9 View Post
    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...

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,879
    Plugin Contributions
    96

    Default Re: Relative path to images

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

  5. #5
    Join Date
    Feb 2010
    Posts
    16
    Plugin Contributions
    0

    Default Re: Relative path to images

    Quote Originally Posted by lat9 View Post
    You could use
    Code:
    <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.

  6. #6
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default 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)

  7. #7
    Join Date
    Feb 2010
    Posts
    16
    Plugin Contributions
    0

    Default Re: Relative path to images

    Quote Originally Posted by Design75 View Post
    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.

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,879
    Plugin Contributions
    96

    Default 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:
    Code:
    <base href="http://localhost/zc151/" />
    Are you using any redirects in your .htaccess file?

  9. #9
    Join Date
    Feb 2010
    Posts
    16
    Plugin Contributions
    0

    Default 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:
    Code:
    <base href="http://localhost/zc151/" />
    Mine looks like:

    Code:
    <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.

 

 

Similar Threads

  1. Replies: 3
    Last Post: 5 Sep 2012, 10:08 AM
  2. Product Images with Relative Links
    By mattgoldfarb in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 31 Mar 2011, 12:47 AM
  3. Add image to ezpage... using relative path?
    By swamyg1 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 26 Dec 2008, 07:42 PM
  4. relative path start with slash?
    By ebaobao in forum General Questions
    Replies: 1
    Last Post: 14 Aug 2008, 12:59 AM
  5. Table with round corners... border image doesn't show on page. Relative path issue?
    By stenio123 in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 30 Jul 2007, 09:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg