digilexic Posted May 29, 2008 Posted May 29, 2008 I was having issues with my images being out of their original aspect ratio when they were viewed on the client side. I did a search of the forums (like a good newbie) and came up with the same answer repeated over and over "delete either the height or width value, DO NOT set it to zero, make sure the field is blank" So I deleted all the height values in the admin section under Configuration->Images. And POOF all my images appeared correctly in the Catalog for the customer side....then a new problem started. It seems that when you do this, it breaks the image sizing on the admin side...so say your product image is 640X480, it actually shows it as full size, filling a good portion of the browser window, making it very hard when you are trying to find the product list or edit button. Especially for my web clients who freak out thinking they broke something. IF I set a valu for height, they display squashed, but at the right size. So I did a little detective work (I am not a coder, but can read and understand alot of code) and posted a question here, which got some help, then buried. Here is what I have figured out. There are two function calls used in the Admin section to display images. One is found in catalog/admin/includes/functions/general.php it is called tep_image The second function is located in catalog/admin/includes/functions/html_output.php and is called tep_info_image When the product/category list is brought up it uses these two function calls to create a string to display an image. In fact tep_info_image makes a call to tep_image! What I think is happening is that since width has a null value, it isnt being passed as a variable to tep_image from tep_info_image. The tep_image function differs from the same function on the client side significantly, as it looks like there is some error checking for null values for width or height and corrections made to the string to adjust for the aspect ratio of the image. The problem I am having is three-fold: Why is there even a tep_info_image function if all it is going to do is call tep_image(other than to display TEXT_IMAGE_NONEXISTANT? ANd how come I cant get the values to transfer from tep_info_image to tep_image? Finally, was this just an oversight in coding, because it seems to me that the tep_image function found in catalog/includes/functions/general.php is definitely better coding than the one found in catalog/admin/includes/functions/general.php I would really like to solve this issue, because my clients start staring into space when I mention aspect ratios and resizing images...then get frusterated when I try to fix it. I have spent 3 days working on this, even copying the entire function from the client to the admin side, to no avail. Could someone with more coding experience point me in the right direction? And is this really a bug or just me being picky?
digilexic Posted May 29, 2008 Author Posted May 29, 2008 SOLUTION: (replace the tep_info_image function in /catalog/admin/includes/functions/general.php with the following code. function tep_info_image($src, $alt, $width = '', $height = '') { if (tep_not_null($src) && (file_exists(DIR_FS_CATALOG_IMAGES . $src)) ) { if ((empty($width) || empty($height)) ) { if ($image_size = @getimagesize(DIR_FS_CATALOG_IMAGES . $src)) { if (empty($width) && tep_not_null($height)) { $ratio = $height / $image_size[1]; $width = intval($image_size[0] * $ratio); // Patch osc-060817 } elseif (tep_not_null($width) && empty($height)) { $ratio = $width / $image_size[0]; $height = intval($image_size[1] * $ratio); // Patch osc-060817 } elseif (empty($width) && empty($height)) { $width = $image_size[0]; $height = $image_size[1]; } } } $image = tep_image(DIR_WS_CATALOG_IMAGES . $src, $alt, $width, $height); } else { $image = TEXT_IMAGE_NONEXISTENT; } return $image; } I isolated the code in the client side that handles the null value width or height, and modified to work in the above function. It had to be put before the call to tep_image, or the null value would never pass through to be processed in the function. This way the value is calculated and filled in BEFORE the call to tep_image Guess after reading spooks post I had to give it one more go...hope this helps others. Seeing as how nobody reported a similar issue that I could find in search engine, I may be the only one. :)
digilexic Posted May 29, 2008 Author Posted May 29, 2008 Not totally solved.... The image still appears full sized when in preview mode. :( (Spent half of night working on it to no avail...)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.