Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

hanguk.openandout.com

Pioneers
  • Posts

    38
  • Joined

  • Last visited

Profile Information

hanguk.openandout.com's Achievements

  1. This contribution would allow generation of thumbs once (not on the fly) according to sizes set by the user in the config. Do you think this is a necessary module? I have to also replace function calls to tep_image_output with its wrapper com_image_output which figures which size image to get (depending on the SIZE parameter passed in). // 5 different sized images are created // they have a different prefix // they are stored in the DIR_WS_THUMBS directory // // one very big wrapper for the tep_image function function com_image_output($src, $alt = '', $type, $parameters = '') { $width=''; $height= ''; $img_prefix=''; // and get prefix for this image's smaller size // com_width and com_height are used in calling the tep_image_output function list ($width, $height, $img_prefix) = com_image_query($src , $type ); if ($img_prefix == 'pib') { // this is the big, the default image size return tep_image(DIR_WS_IMAGES . $src, $alt , $width , $height , $parameters ); } $thumbfile = DIR_WS_THUMBS . $img_prefix . '_' . $src; if (file_exists ($thumbfile)) { return tep_image($thumbfile, $alt , $width , $height , $parameters ); } else { // need to make the thumb // generate the thumb if necessary copy(DIR_WS_IMAGES . $src, $thumbfile); system("mogrify -resize '" . $width . "x" . $height . "' " . $thumbfile ); return tep_image($thumbfile , $alt , $width , $height , $parameters ); } } // called above // called in some places to set table width depending on image size // function com_image_query($src , $type ) { $width = ''; $height = ''; $img_prefix = ''; // Calcul des nouvelles dimensions // add @ to suppress errors if category file does not exist yet list($width, $height) = @getimagesize(DIR_WS_IMAGES . $src); // return array($width, $height); if ($type == PRODUCT_INFO_BIG ) { $img_prefix = 'pib'; if ($width > $height ) { $width = PRODUCT_INFO_WIDTH; $height = PRODUCT_INFO_HEIGHT; } else if ($height > $width ) { $width = PRODUCT_INFO_WIDTH2; $height = PRODUCT_INFO_HEIGHT2; } else { // there are no categories $width = PRODUCT_INFO_WIDTH; $height = PRODUCT_INFO_HEIGHT; } } if ($type == THUMB_SIZE || $type == PRODUCT_INFO_SMALL ) { $img_prefix = 'ts'; if ($width > $height ) { $width = SMALL_IMAGE_WIDTH; $height = SMALL_IMAGE_HEIGHT; } else if ($height > $width ) { $width = SMALL_IMAGE_WIDTH2; $height = SMALL_IMAGE_HEIGHT2; } else { // there are no categories $width = SMALL_IMAGE_WIDTH; $height = SMALL_IMAGE_HEIGHT; } } return array($width, $height, $img_prefix); } // all the things in caps above are set in the configuration table +-------------------------------+---------------------+ | configuration_key | configuration_value | +-------------------------------+---------------------+ | SMALL_IMAGE_WIDTH | 100 | | SMALL_IMAGE_HEIGHT | 80 | | PRODUCT_LISTING_IMAGE_WIDTH | 216 | | PRODUCT_LISTING_IMAGE_HEIGHT | 161 | | PRODUCT_INFO_WIDTH | 330px | | PRODUCT_INFO_HEIGHT | 280 | | SMALL_IMAGE_WIDTH2 | 80 | | SMALL_IMAGE_HEIGHT2 | 100 | | PRODUCT_LISTING_IMAGE_HEIGHT2 | 216 | | PRODUCT_LISTING_IMAGE_WIDTH2 | 161 | | PRODUCT_INFO_DETAIL_HEIGHT | 400px | | PRODUCT_INFO_DETAIL_WIDTH | 298px | | PRODUCT_INFO_DETAIL_HEIGHT2 | 298px | | PRODUCT_INFO_DETAIL_WIDTH2 | 400px | | PRODUCT_INFO_WIDTH2 | 280 | | PRODUCT_INFO_HEIGHT2 | 330px | +-------------------------------+---------------------+ does this look useful to anybody ????
  2. In order for it to automatically calculate, is it necessary to set the configuration variable CALCULATE_IMAGE_SIZE to 1 in the configuration table?
×
×
  • Create New...