Loaded Commerce Community

Banner


Board index » Web Design and Development » Contribution Garage

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: is this a bug?
PostPosted: Sat Oct 02, 2004 4:37 am 
Offline
CRE Freak
User avatar

Joined: Sat Oct 02, 2004 12:00 am
Posts: 74
Loaded 6 stock just downloaded yesterday.

while adding the GD thumbs you gotta edit the includes/functions/html_output.php

you comment out the section

Code:
////
// The HTML image wrapper function
//  function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
//    if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
//      return false;
//    }


and enter this in its place

Code:
// "On the Fly Thumbnailer" using PHP GD Graphics Library by Nathan Welch (v1.5)
// Scales product images dynamically, resulting in smaller file sizes, and keeps
// proper image ratio.  Used in conjunction with product_thumb.php t/n generator.
function tep_image($src, $alt = '', $width = '', $height = '', $params = '') {

    // Set default image variable and code
      $image = '<img src="' . $src . '"';

    // Don't calculate if the image is set to a "%" width
      if (strstr($width,'%') == false || strstr($height,'%') == false) {
        $dont_calculate = 0;
    } else {
        $dont_calculate = 1;       
      }   

    // Do we calculate the image size?
      if (CONFIG_CALCULATE_IMAGE_SIZE && !$dont_calculate) {

        // Get the image's information
            if ($image_size = @getimagesize($src)) {
            
                $ratio = $image_size[1] / $image_size[0];
            
                // Set the width and height to the proper ratio
                  if (!$width && $height) {
                $ratio = $height / $image_size[1];
                $width = intval($image_size[0] * $ratio);
            } elseif ($width && !$height) {
                $ratio = $width / $image_size[0];
                $height = intval($image_size[1] * $ratio);
            } elseif (!$width && !$height) {
                $width = $image_size[0];
                $height = $image_size[1];
            }

            // Scale the image if larger than the set width or height
                  if ($image_size[0] > $width || $image_size[1] > $height) {
                $rx = $image_size[0] / $width;
                $ry = $image_size[1] / $height;

                if ($rx < $ry) {
                    $width = intval($height / $ratio);
                } else {
                    $height = intval($width * $ratio);
                }

                $image = '<img src="product_thumb.php?img='.$src.'&w='.tep_output_string($width).'&h='.tep_output_string($height).'"';
            }
                  
        } elseif (IMAGE_REQUIRED == 'false') {
              return '';
        }
    }

    // Add remaining image parameters if they exist
      if ($width) {
        $image .= ' width="' . tep_output_string($width) . '"';
    }
      
    if ($height) {
        $image .= ' height="' . tep_output_string($height) . '"';
    }       

    if ($params != '') {
        $image .= ' ' . $params;
    }

    $image .= ' border="0" alt=" ' . tep_output_string($alt) . ' "';
      
      if ($alt)
        $image .= ' title=" ' . tep_output_string($alt) . ' "';

    $image .= '>';      
      
    return $image;
}


after properly installing the mod the site gets an error on line whatever with an un expected } near line whatever

this error seems to be in the function below the code i just modified...

Code:
// 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) . ' "';
    }

    if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {
      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];
        }
      } 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;
  }


the error is the very last IF statement... i got the error to go away by changing the last IF statement as follows
Code:
if (tep_not_null($parameters)) { $image .= ' ' . $parameters;


is this a bug in the code where someone missed the { on the IF and it decided to error after my modification? or did i just luck out when i fixed this?

Thanks and hope this might be helpfull and maybe someone can confirm this and we can get this bug fixed if it is one :P


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 10:26 pm 
Offline
CRE Legend

Joined: Sun Nov 09, 2003 1:00 am
Posts: 7301
Location: Baconton, GA USA
It rather appears that way to me.

David

_________________
My CRE Loaded FAQ List
CRE Loaded Hosting


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

Board index » Web Design and Development » Contribution Garage

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
It is currently Wed May 23, 2012 9:37 pm
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Login

Forums Latest Activity

Top Listing

1. Cart2Cart - Shopping...
    Category: Shopping Cart Database Conversion Scripts
    
2. Points & Rewards PLUS!...
    Category: Add-Ons
    
3. Configuration Server...
    Category: Fixes
    
4. Credit Card with CCV
    Category: Payment Modules
    
5. CC7333_ATS
    Category: Templates
    
Show more...

© CRE Loaded is a product of Chain Reaction Ecommerce, Inc. Usage & Privacy Policy