Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2010
    Location
    Las Palmas de Gran Canaria, Spain
    Posts
    5
    Plugin Contributions
    0

    bug zen_image ambiguous value for $src parameter

    Hi,

    First time posting but searched the site and FAQs and found no love, so here's my question/report.

    Problem: The value for $src (first parameter of zen_image) is sometimes expected to be web site-relative and other times filesystem-relative

    Precondition: mod_rewrite is enabled and functioning (or some other method is used to append subdirectories to store URL - e.g. http://mysite.com/store/index.php becomes http://mysite.com/store/clothes/men/index.php)

    1. call zen_image with a $src value of 'images/medium/myProductImage_MED.jpg'

    Expected Result: an IMG tag with the width and height set to the actual width and height of the selected image

    Actual Result: an IMG tag with width and height of the default (small) product image

    Workaround: I am unaware of a way to work-around this.

    I see in zen_image that there are a few calls to file_exists($src) (line 232, for example) but if the $src value provided is web site-relative (as, I assume, it should be) or if the site is using any kind of virtual file structure, such a value will always return false.

    In my case I'm pretty sure the code is failing when calling @getimagesize($src) (lines 257 and 277 of includes/functions/html_output.php) and is then defaulting the the small image size. I can't think of any way to work around this and I've been racking my brain for a couple hours on this one issue.

    Any suggestions/thoughts would be greatly appreciated (even including suggesting to not use zen_image).

    Thanks.

    Ted Stresen-Reuter
    http://chicagoitsystems.com

    Zen-Cart: 1.5.1
    PHP 5.3.4
    MySQL: 5.1.30
    Apache: 2.2something
    No add-ons installed
    No customizations to core files
    Last edited by chicagoitsystems; 19 Dec 2012 at 12:27 PM. Reason: Added system version details

  2. #2
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: zen_image ambiguous value for $src parameter

    If I remember correctly (feel free to correct me if I am wrong), Zen Cart typically expects all images to be relative to HTTP_SERVER + DIR_WS_CATALOG or HTTPS_SERVER + DIR_WS_HTTPS_CATALOG. In most of the templates a "base href" meta tag is then used to tell browsers all images and resources are relative to the value of the "base href".

    There is also a define "DIR_FS_CATALOG" which should point to the root filesystem directory for your installation. You may be able to find a way to use this define (in particular when the "file_exists" and "getimagesize" functions are used).
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  3. #3
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: zen_image ambiguous value for $src parameter

    Problem: The value for $src (first parameter of zen_image) is sometimes expected to be web site-relative and other times filesystem-relative
    Post links to these two instances

    like mysitedotcom
    Zen-Venom Get Bitten

  4. #4
    Join Date
    Jun 2010
    Location
    Las Palmas de Gran Canaria, Spain
    Posts
    5
    Plugin Contributions
    0

    Default Re: zen_image ambiguous value for $src parameter

    Quote Originally Posted by kobra View Post
    Post links to these two instances

    like mysitedotcom
    Yes, those are examples of URLs, not real ones. Would it help for you to see the resulting HTML?

  5. #5
    Join Date
    Jun 2010
    Location
    Las Palmas de Gran Canaria, Spain
    Posts
    5
    Plugin Contributions
    0

    Default Re: zen_image ambiguous value for $src parameter

    Quote Originally Posted by lhungil View Post
    If I remember correctly (feel free to correct me if I am wrong), Zen Cart typically expects all images to be relative to HTTP_SERVER + DIR_WS_CATALOG or HTTPS_SERVER + DIR_WS_HTTPS_CATALOG. In most of the templates a "base href" meta tag is then used to tell browsers all images and resources are relative to the value of the "base href".
    That seems reasonable. Unfortunately, I'm working on a project under a tight deadline and don't have the time to really research the methodology. It would be great to have this documented with some examples of how it should be done... But now that I look at my template, I see that indeed it's missing the base href... could be the culprit!

    Quote Originally Posted by lhungil View Post
    There is also a define "DIR_FS_CATALOG" which should point to the root filesystem directory for your installation. You may be able to find a way to use this define (in particular when the "file_exists" and "getimagesize" functions are used).
    Right, but the reason I made this original post (and classify it as a bug) is because the incoming value of $src seems to be a URL path rather than a system path and thus it seems unlikely to work (and in fact didn't appear to work on my dev machine), but I must be missing something obvious...

    Thanks for the pointers, will look into the base href option...

    Ted

  6. #6
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: zen_image ambiguous value for $src parameter

    Would it help for you to see the resulting HTML?
    If you can post real url's
    Zen-Venom Get Bitten

  7. #7
    Join Date
    Jun 2010
    Location
    Las Palmas de Gran Canaria, Spain
    Posts
    5
    Plugin Contributions
    0

    Default Re: zen_image ambiguous value for $src parameter

    Quote Originally Posted by kobra View Post
    If you can post real url's
    I can't right now because it's still in development. That said, the OR's (original responder) reminder that templates should have a base href seems to have solved the problem (in the sense that all the images are displaying properly).

    What I can't quite understand, though, is how getimagesize and file_exists are returning anything other than false when sent a path that shouldn't resolve... (ponders for a moment)

    On second thought, Zen-Cart is based on a "front controller" program design. I suspect the reason these functions don't fail is because they search for files relative to index.php (which "includes" all support files) and if the path is relative to the DIR_WS_CATALOG define then it should work.

    So, maybe this "bug" should be closed but a "base href in all templates" requirement should be added to template documentation (if it's not already there).

    Thanks a lot for helping me see the light on this. Everything seems to be working just fine now.

    Sincerely,

    Ted Stresen-Reuter

 

 

Similar Threads

  1. v151 Option Value URL parameter?
    By philip937 in forum General Questions
    Replies: 13
    Last Post: 14 Dec 2014, 05:58 AM
  2. Replies: 2
    Last Post: 24 Nov 2012, 02:48 AM
  3. v150 How to set Title different as Alt for zen_image?
    By tips007 in forum General Questions
    Replies: 3
    Last Post: 29 Oct 2012, 08:44 PM
  4. how to modify the image SRC for image-handler images?
    By jason1116 in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 2 Sep 2009, 01:00 PM
  5. IH2 bug: zen_image doesnt take parameter
    By yellow1912 in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 9 Dec 2008, 06:00 PM

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