Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

donturner

Members
  • Content count

    5
  • Joined

  • Last visited

Posts posted by donturner


  1. Must be something to do with the arguments you're sending to the function, add:

     

    print $src;

     

    immediately after:

     

    function tep_image($src, $alt = '', $width = '', $height = '', $params = '') {

     

     

    In order to see what you're passing in, then check if that image exists and that the path is correct. You'll probably find that the path is wrong.

     

    Good luck,

     

    Don


  2. This should work but I haven't tested it so no guarantees ;) Hope it helps!

     

    Don

     

    // "On the Fly" Auto Thumbnailer using GD Library originally Nate Welch (v1.5) Updated by various contributors (v1.7.1)
    // 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 . '"';
    
    // Dont 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 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) {
    
    $width = intval($height / $ratio);
    
    } elseif ($width && !$height) {
    
    $height = intval($width * $ratio);
    
    } elseif (!$width && !$height) {
    
    $width = $image_size[0];
    $height = $image_size[1];
    }
    
    
     $image = '<img src="product_thumb.php?img='.$src.'&w='.tep_output_string($width).'&h='.tep_output_string($height).'"';
    
    
      } elseif (IMAGE_REQUIRED == 'false') {
        return '';
      } else {
         //the image did not exist and it is required so return a default image     
         $image = '<img src="'.DIR_WS_IMAGES.'notavailable.gif" ';
      }
    }
    
    // Add remaining image parameters if they exist
    if ($width) {
      $image .= ' width="' . tep_output_string($width) . '"';
    }
    
    if ($height) {
      $image .= ' height="' . tep_output_string($height) . '"';
    }
    
    if (tep_not_null($params)) $image .= ' ' . $params;
    
    $image .= ' border="0" alt="' . tep_output_string($alt) . '"';
    
    if (tep_not_null($alt)) {
      $image .= ' title="' . tep_output_string($alt) . '"';
    }
    
    $image .= '>';
    
    return $image;
    }


  3. Can't see anything wrong with that, I would put:

     

    print "width: ".$width;

    print "height: ".$height;

     

    at the start of the function and track the values throughout to see where it's getting set to zero.

     

    Alternatively you could try this modified version of the function which I wrote, it takes out some redundant code used to calculate the ratio of height to width:

     

    // "On the Fly" Auto Thumbnailer using GD Library originally Nate Welch (v1.5) Updated by various contributors (v1.7.1)
    // 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 . '"';
    
     // Dont 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 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) {
    
    $width = intval($height / $ratio);
    
    } elseif ($width && !$height) {
    
    $height = intval($width * $ratio);
    
    } elseif (!$width && !$height) {
    
    $width = $image_size[0];
    $height = $image_size[1];
    }
    
    
      $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 (tep_not_null($params)) $image .= ' ' . $params;
    
     $image .= ' border="0" alt="' . tep_output_string($alt) . '"';
    
     if (tep_not_null($alt)) {
       $image .= ' title="' . tep_output_string($alt) . '"';
     }
    
     $image .= '>';
    
     return $image;
    }


  4. Hello everyone.

     

    Sorry if this question had been asked before. Can't find my answer through the search.

     

    I have installed the 'On the Fly' Auto Thumbnailer using GD Library 1.9.1. Everything seems to work fine except that I kept getting this error message on top of the shop.

     

    They are referring to the following lines in includes/functions/html_output.php.

    	$rx = $image_size[0] / $width; 
    $ry = $image_size[1] / $height;

    I have set the Images Configuration as follow.

     

    Has anyone encountered the same problem or will be able to tell me where have I gone wrong? All help is greatly appreciated.

     

    Thanks

     

    Hi rezdwan,

     

    The division by zero error is caused by the $width and $height variables being set to either null or empty string. Post your tep_image() function here and I'll take a look at it.

     

    Don

×