easyweb Posted August 15, 2005 Posted August 15, 2005 (edited) Hi, I have done everything that it told me to do in the installation, but nothing has changed. <?php /*This modification allows the existing image wrapper function to consider your configured image width and height variables as maximum values, not absolute values. It's almost like your configured width and height variables define a box within which your images will fit while maintaining their original aspect ratio (instead of stretching one of the images dimensions). Files modified to allow images to not be stretched: includes/functions/html_output.php ?- modified actual tep_image function to calculate if stretch is set to false New Function: */ //// // The HTML image wrapper function //EC - modified to allow calls to this function to determine whether or not to allow images to stretch // If stretch is set to false, the width and height attributes are considered as "maximum" values, rather than absolute values function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '', $stretch='true') { ?if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) ?{ ? return false; ?} ?// alt is added to the img tag even if it is null to prevent browsers from outputting ?// the image filename as default ?$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; ?if (tep_not_null($alt)) ?{ ? $image .= ' title=" ' . tep_output_string($alt) . ' "'; ?} ?//EC - modified - removed check on if width or height are null. Change made for no-stretch ability ?if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') ) ?{ ? if ($image_size = @getimagesize($src)) ? { ? ?if (empty($width) && tep_not_null($height)) ? ?{ ? ? ?$ratio = $height / $image_size[1]; ? ? ?$width = $image_size[0] * $ratio; ? ?} ? ?elseif (tep_not_null($width) && empty($height)) ? ?{ ? ? ?$ratio = $width / $image_size[0]; ? ? ?$height = $image_size[1] * $ratio; ? ?} ? ?elseif (empty($width) && empty($height)) ? ?{ ? ? ?$width = $image_size[0]; ? ? ?$height = $image_size[1]; ? ?} ? ?//EC - added the following elseif for calculating based on stretch/no-stretch ? ?elseif (tep_not_null($width) && tep_not_null($height)) ? ?{ ? ? if ($stretch=='false') ? ? { ? ? ?$new_ratio=$height / $width; ? ? ?$image_ratio=$image_size[1] / $image_size[0]; ? ? ?if ($new_ratio >= $image_ratio) ? ? ?{ ? ? ? $height=$image_size[1]*($width/$image_size[0]); ? ? ?} ? ? ?else ? ? ?{ ? ? ? $width=$image_size[0]*($height/$image_size[1]); ? ? ?} ? ? } ? ?} ? } ? elseif (IMAGE_REQUIRED == 'false') ? { ? ?return false; ? } ?} ?if (tep_not_null($width) && tep_not_null($height)) ?{ ? $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; ?} ?if (tep_not_null($parameters)) $image .= ' ' . $parameters; ?$image .= '>'; ?return $image; } ?HERE? /* Replacing the old function with this new one will have no effect until you find the calls to this function and modify the appropriate ones to send the value "false" for the new variable "stretch". The following files are the ones I modified for my site (I only concerned myself with the stretching of small images). Keep in mind when modifying these function calls that the tep_image function has a variable that it looks for after "height" and before the new "stretch" variable. You will find that some of the function calls only pass variables up to the "height" variable, and don't pass a value for the "parameters" variable. In these cases, you must send an empty "paramters" value before your "stretch" value. IE: if the original function call looks something like this: */ tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) /* Then the new function call will be: */ tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,'','false') /* Notice the empty parameter after "SMALL_IMAGE_HEIGHT" and before "'false'". Because I was focusing only on the display of small images, I found the easiest way to find all these function calls was to search for the string "SMALL_IMAGE_HEIGHT". The line numbers given are from my slightly customized version of osCommerce, so may be different from yours. Sorry, I don't have time right now to turn this into a "real" contribution or provide any more extensive documentation... I would eventually like to integrate it and provide a configuration setting to turn it on or off from admin. products_new.php ?- modified call to tep_image at around line 89 to pass "false" for stretch product_reviews.php ?- modified 2 calls to tep_image at around line 182-185 to pass "false" for stretch product_reviews_info.php ?- modified 2 calls to tep_image at around line 136-139 to pass "false" for stretch product_reviews_write.php ?- modified 2 calls to tep_image at around line 201-204 to pass "false" for stretch reviews.php ?- modified call to tep_image at around line 93 to pass "false" for stretch shopping_cart.php ?- modified call to tep_image at around line 117 to pass "false" for stretch specials.php ?- modified call to tep_image at around line 82 to pass "false" for stretch admin/categories.php ?- modified call to tep_image at around line 766 to pass "false" for stretch admin/reviews.php ?- modified 2 calls to tep_image at around lines 91 and 141 to pass "false" for stretch includes/boxes/reviews.php ?- modified call to tep_image at around line 38 to pass "false" for stretch includes/boxes/specials.php ?- modified call to tep_image at around line 26 to pass "false" for stretch includes/boxes/whats_new.php ?- modified call to tep_image at around line 36 to pass "false" for stretch includes/modules/also_purchased_products.php ?- modified call to tep_image at around line 32 to pass "false" for stretch includes/modules/family_listing.php ?- modified 2 calls to tep_image at around line 131-134 to pass "false" for stretch includes/modules/new_products.php ?- modified call to tep_image at around line 33 to pass "false" for stretch includes/modules/products_listing.php ?- modified 2 calls to tep_image at around line 125-128 to pass "false" for stretch */ ?> And I changed my html_output.php up to ?HERE?. Do I need to do more? because i didn't really understand below the ?HERE?. Can anyone help please? Thanks Edited August 15, 2005 by easyweb Quote
241 Posted August 19, 2005 Posted August 19, 2005 As the instructions state you will need to modify the calls as shown in the examples mentioned in all the information below ?HERE? Quote No longer giving free advice. Please place deposit in meter slot provided. Individual: [=] SME: [==] Corporation: [===] If deposit does not fit one of the slots provided then you are asking too much! Is your Osc dated try Phoenix raising oscommerce from the ashes.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.