Guest Posted September 14, 2002 Share Posted September 14, 2002 Alright I just posted this Contrib and you can get it at: http://www.oscommerce.com/downloads.php/co...ions,493/type,3 Quote Link to comment Share on other sites More sharing options...
shahed Posted September 14, 2002 Share Posted September 14, 2002 Thanks for your contribution, i'm getting this error: Parse error: parse error, unexpected $ in /home/xxx/xxx/xxx/includes/functions/html_output.php on line 365 Do I need to change in 2 places? there are 2 html_output Quote Link to comment Share on other sites More sharing options...
Guest Posted September 14, 2002 Share Posted September 14, 2002 Thanks for your contribution, i'm getting this error:Parse error: parse error, unexpected $ in /home/xxx/xxx/xxx/includes/functions/html_output.php on line 365 Do I need to change in 2 places? there are 2 html_output I wouldn't worry too much about the admin side of things. I couldn't tell you why you're getting that error except that maybe you have a very old or very new snapshot that possibly may not work, but my php and programming skill-age is very small. Quote Link to comment Share on other sites More sharing options...
Ajeh Posted September 14, 2002 Share Posted September 14, 2002 I believe there is a missing { in the code and when there is no image but it is defined you get division by zero errors. I had this same issue with other code I had once seen posted and ended up re-writting for similar issues. This seems to work on most sites ... but no promises for all sites :D Replace (I rename the original tep_image to tep_image_old) all of function tep_image with this: function tep_image($src, $alt = '', $width = '', $height = '', $params = '') { if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED=='false') ) { return; } $image = '<img src="' . $src . '" border="0" alt=" ' . htmlspecialchars($alt) . ' "'; if ((strstr($width,'%')!='') || (strstr($height,'%')!='')) { $dont_calculate = 1; } if ( (CONFIG_CALCULATE_IMAGE_SIZE) && ((!$width) || (!$height)) ) { if ($image_size = @getimagesize($src)) { if ( (!$width) && ($height) ) { $ratio = $height / $image_size[1]; $width = $image_size[0] * $ratio; } elseif ( ($width) && (!$height) ) { $ratio = $width / $image_size[0]; $height = $image_size[1] * $ratio; } elseif ( (!$width) && (!$height) ) { $width = $image_size[0]; $height = $image_size[1]; } } elseif (IMAGE_REQUIRED=='false') { return ''; } } if ( CONFIG_CALCULATE_IMAGE_SIZE && (!$dont_calculate) ){ if ($image_size = @getimagesize($src)) { $ratio = $image_size[1] / $image_size[0]; // real ratio // do we need scaling if (($image_size[0] > $width) || ($image_size[1] > $height)) { $rx = $image_size[0] / $width; $ry = $image_size[1] / $height; if ($rx < $ry) { $width = $height / $ratio; } else { $height = $width * $ratio; } } else { $rx = $image_size[0] / $width; $ry = $image_size[1] / $height; if ($rx < $ry) { $width = $height / $ratio; } else { $height = $width * $ratio; } } } } if ( ($width) && ($height) ) { $image .= ' width="' . $width . '" height="' . $height . '"'; } if ($params != '') { $image .= ' ' . $params; } $image .= '>'; return $image; } Let me know if this fails for people who try it. I have not found out why it fails for some, unless my last fix to it was the solution. Quote Link to comment Share on other sites More sharing options...
Guest Posted September 14, 2002 Share Posted September 14, 2002 Thanks Linda, I think that might be the trick, I've been using place holder images. So I never ran into missing image problems. Quote Link to comment Share on other sites More sharing options...
Ajeh Posted September 14, 2002 Share Posted September 14, 2002 To see the difference in original verse the code I tossed in there: Old version: http://www.thewebmakerscorner.com/oscdefa/....php?cPath=45_1 New version: http://www.thewebmakerscorner.com/working/....php?cPath=45_1 The printer and the mouse show the distortion and correction best Quote Link to comment Share on other sites More sharing options...
Ajeh Posted September 14, 2002 Share Posted September 14, 2002 Thanks Linda, I think that might be the trick, I've been using place holder images. So I never ran into missing image problems. By coincidence the site I am working on right now is a duplicate of another site without the images loaded so it was real apparent when I got 40 errors on the first page then when I went to a page with just 2 images and had 2 errors I remembered an error I got first time I ever tried to change this code based on a suggestion someone else made to fix this. And no, I cannot for the life of me recall who first posted the code I modified for images :shock: Quote Link to comment Share on other sites More sharing options...
Snowman Posted September 14, 2002 Share Posted September 14, 2002 Linda im not sure if im understanding this properly....(stupid pills at work) but your code will take any image and resize it correctly so that a thumbnail isnt out of proportion is that right??? Currently i use the big image mod and load the full size image into it and then create a copy of each image and re-size it to a size of 140x120 and save them with _sml added to their names and upload them as the normal image. This ensure that all my product images are exactly 140x120 Does this code remove the need to do that??? I kind of want everything laying out in a neat uniform way so will this do this or do you think i shoudl stick to the way i do it now??? what do you think? Quote Link to comment Share on other sites More sharing options...
OSC-Spain Posted September 14, 2002 Share Posted September 14, 2002 It works fine for me Linda, thx! Regards, Fernando. Quote Link to comment Share on other sites More sharing options...
Ajeh Posted September 15, 2002 Share Posted September 15, 2002 Linda im not sure if im understanding this properly....(stupid pills at work) but your code will take any image and resize it correctly so that a thumbnail isnt out of proportion is that right??? It's just a replacement of function tep_image. When I use it, all of my images are no longer distorted. Any code that uses the tep_image for displaying the image will now display a proportioned image based on the settings in Admin. Usually I create proper sized images, but often times, there are those images or jobs where you are just tired of being 'perfect' on your settings or the image just isn't going to fit or look right. This revised routine appears to handle it for me. Quote Link to comment Share on other sites More sharing options...
Guest Posted September 17, 2002 Share Posted September 17, 2002 My snapshot is around jun. 25/02- any ideas? here is what I have in there: function tep_image($src, $alt = '', $width = '', $height = '', $params = '') { ? if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED=='false') ) { ? ? return; ? } ? $image = '<img src="' . $src . '" border="0" alt=" ' . htmlspecialchars($alt) . ' "'; ? if ((strstr($width,'%')!='') || (strstr($height,'%')!='')) { ? ? $dont_calculate = 1; ? } ? if ( (CONFIG_CALCULATE_IMAGE_SIZE) && ((!$width) || (!$height)) ) { ? ? if ($image_size = @getimagesize($src)) { ? ? ? if ( (!$width) && ($height) ) { ? ? ? ? $ratio = $height / $image_size[1]; ? ? ? ? $width = $image_size[0] * $ratio; ? ? ? } elseif ( ($width) && (!$height) ) { ? ? ? ? $ratio = $width / $image_size[0]; ? ? ? ? $height = $image_size[1] * $ratio; ? ? ? } elseif ( (!$width) && (!$height) ) { ? ? ? ? $width = $image_size[0]; ? ? ? ? $height = $image_size[1]; ? ? ? } ? ? } elseif (IMAGE_REQUIRED=='false') { ? ? ? return ''; ? ? } ? } ? if ( CONFIG_CALCULATE_IMAGE_SIZE && (!$dont_calculate) ){ ? ? if ($image_size = @getimagesize($src)) { ? ? ? $ratio = $image_size[1] / $image_size[0]; // real ratio ? ? ? // do we need scaling ? ? ? if (($image_size[0] > $width) || ($image_size[1] > $height)) { ? ? ? ? $rx = $image_size[0] / $width; ? ? ? ? $ry = $image_size[1] / $height; ? ? ? ? if ($rx < $ry) { ? ? ? ? ? $width = $height / $ratio; ? ? ? ? } else { ? ? ? ? ? $height = $width * $ratio; ? ? ? ? } ? ? ? } else { ? ? ? ? $rx = $image_size[0] / $width; ? ? ? ? $ry = $image_size[1] / $height; ? ? ? ? if ($rx < $ry) { ? ? ? ? ? $width = $height / $ratio; ? ? ? ? } else { ? ? ? ? ? $height = $width * $ratio; ? ? ? ? } ? ? ? } ? ? } ? } ? if ( ($width) && ($height) ) { ? ? $image .= ' width="' . $width . '" height="' . $height . '"'; ? } ? if ($params != '') { ? ? $image .= ' ' . $params; ? } ? $image .= '>'; ? return $image; } //// // The HTML form submit button wrapper function // Outputs a button in the selected language function tep_image_submit($image, $alt) { global $language; $image_submit = '<input type="image" src="' . DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image . '" border="0" alt="' . htmlspecialchars($alt) . '"'; if (tep_not_null($alt)) { $image_submit .= ' title=" ' . htmlspecialchars($alt) . ' ">'; } return $image_submit; } Quote Link to comment Share on other sites More sharing options...
Guest Posted September 20, 2002 Share Posted September 20, 2002 Hey has anyone got this to work in conjunction with big images?? Quote Link to comment Share on other sites More sharing options...
HQ Secure Posted September 25, 2002 Share Posted September 25, 2002 I'm using 2002/08/02 and with Linda's code I had to remove a } on line 157. Seems ok now. Quote Link to comment Share on other sites More sharing options...
Jason G Posted October 13, 2003 Share Posted October 13, 2003 I'm a novice at sticking things in the database. Nonetheless, I'm using myphpadmin and I don't see "admin image config" anywhere. Can someone tell me where (exactly) to stick the SQL string for this hack? Sincerely, Jason Quote Link to comment Share on other sites More sharing options...
Jason G Posted October 13, 2003 Share Posted October 13, 2003 Ok. I'm getting it. I see the places in mysql that need the code. I received an error, though. Error SQL-query : `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `date_added` , `set_function` 'IMAGE_CONSTRAIN_PROPORTIONS', 'true', 'Maintain image proportions when setting sizes', 4, 9, now( ) , 'tep_cfg_select_option(array(\'true\', \'false\'),' ) MySQL said: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'configuration_title` , `configuration_key` , `configuration_v Back Any ideas for what I should do? The "now()" was highlighted as something it didn't like. JG Quote Link to comment Share on other sites More sharing options...
Jason G Posted October 13, 2003 Share Posted October 13, 2003 Ok. It seems that I've done that part correctly. Now, I have this error on my page: Parse error: parse error, expecting `')'' in /home/jcsm/public_html/cart/includes/functions/html_output.php on line 291 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/jcsm/public_html/cart/includes/functions/html_output.php:291) in /home/jcsm/public_html/cart/includes/functions/sessions.php on line 67 You can see it at http://jcsm.org/cart/ Any ideas? JG Quote Link to comment Share on other sites More sharing options...
Jason G Posted October 13, 2003 Share Posted October 13, 2003 This error has popped up, too: Fatal error: Call to undefined function: tep_draw_pull_down_menu() in /home/jcsm/public_html/cart/includes/boxes/currencies.php on line 41 JG Quote Link to comment Share on other sites More sharing options...
Jason G Posted October 13, 2003 Share Posted October 13, 2003 Ok. The errors are gone. I replaced the file with my backup copy. Now, the problem is finding the first part of this code. It doesn't exist. How can I replace it if I cannot find it? ////////////////////////////////////////////////////////// //FIND THE CODE LIKE THIS: (in function tep_image) ///////////////////////////////////////////////////////// if ( ($width) && ($height) ) { $image .= ' width="' . tep_parse_input_field_data($width, array('"' => '"')) . '" height="' . tep_parse_input _field_data($height, array('"' => '"')) . '"'; } //////////////////////////////////////////////////////////////////////////// // AND REPLACE WITH THIS: ( or simply insert the part between BEGIN & END) //////////////////////////////////////////////////////////////////////////// if ( ($width) && ($height) ) { // BEGIN Code inserted to maintain proportions of images. if (IMAGE_CONSTRAIN_PROPORTIONS == 'true') { $image_size = @getimagesize($src); $ratio = $width / $image_size[0]; if ($image_size[1]*$ratio > $height) { $ratio = $height / $image_size[1]; $width = $image_size[0] * $ratio; } else { $height = $image_size[1] * $ratio; } } // END Code inserted to maintain proportions of images. $image .= ' width="' . tep_parse_input_field_data($width, array('"' => '"')) . '" height="' . tep_parse_input _field_data($height, array('"' => '"')) . '"'; } JG Quote Link to comment Share on other sites More sharing options...
Jason G Posted October 13, 2003 Share Posted October 13, 2003 Anyone know the right code for this version? $Id: html_output.php,v 1.56 2003/07/09 01:15:48 hpdl Exp $ JG Quote Link to comment Share on other sites More sharing options...
dr_lucas Posted March 21, 2004 Share Posted March 21, 2004 I have the same problem, I can't find the code to replace on a new installtion of oscommerce (version $Id: html_output.php,v 1.56 2003/07/09 01:15:48 hpdl Exp $) :( Can anyone please help? Quote Did I help you? Click "Like" or "Thanks"! It's free of charge. :)My contributions:Total Configuration (newly updated 07/2018, for both osC 2.2 and 2.3.4.1 BS Frozen CE)User Tracking with Admin 1.0 (newly updated 07/2018)FedEx - Web Services v9, FAQ System , Who's Online Enhancement, Order Editor, MoneyBookers IPN, Ship in Cart (MS2), Admin Products Paging, Margin Report v1.00, 2Checkout INS / IPN (Instant Notification System) for MS2.2, Visitor Web Stats, Time Zone Offset - Adjust to match your location, Category Meta Tags Link to comment Share on other sites More sharing options...
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.