Guest Posted June 3, 2009 Posted June 3, 2009 Ok, so I have been working on my osCommerce powered shop for the past few weeks and the one major problem I have yet to figure out is the category images. I decided to install the Automatic Thumbnail contibution (small and easy). The only file that needed to be changed was the html_output.php. However, upon doing so it screwed up my custom template's layout. I have included some images below so you can see what happens. Unmodified Shop Modified Shop As you can see it causes some sort of disruption in the spacing around certain objects (marked by red arrows). What I need is for the contribution to work without it conflicting with my custom template. I narrowed down the changes between my old html_output.php code and my new html_output.php code to the following changes. (Warning: long code) Original Section from html_output.php //// // 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; } // 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 = intval($image_size[0] * $ratio); } elseif (tep_not_null($width) && empty($height)) { $ratio = $width / $image_size[0]; $height = intval($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; } Replacement Code for Above //// // 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; } if ($image_size = @getimagesize($src)) { if ((CONFIG_CALCULATE_IMAGE_SIZE == 'true' && $src != DIR_WS_IMAGES . 'pixel_black.gif' && $src != DIR_WS_IMAGES . 'pixel_trans.gif' && $src != DIR_WS_IMAGES . 'pixel_silver.gif' )) { if ( ($width) || ($height) ) { if ( $width=="100%" ) { $width = $image_size[0]; } elseif ( $height=="100%" ) { $height = $image_size[1]; } elseif ( $width==0 ) { unset($width); } elseif ( $height==0 ) { unset($height); } $src=thumbimage(DIR_FS_CATALOG . '/' .$src, $width, $height, 1, 1, DIR_FS_CATALOG . '/' . DIR_WS_IMAGES . 'thumbs_cache'); if ((($image_size[1]/$height) > ($image_size[0]/$width) ) && $height>0){ $width=ceil(($image_size[0]/$image_size[1])* $height); } elseif ($width>0) { $height=ceil($width/($image_size[0]/$image_size[1])); } } } } elseif (IMAGE_REQUIRED == 'false') { return ''; } // 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 (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; } Added to the End function thumbimage ($image, $x, $y, $aspectratio, $resize, $cachedir){ define(JPEGQUALITY, 95); /*############################################## # - Thumbnail-Script v1.3 - # # Generating thumbnails 'on-the-fly' with PHP # # # # © by Christian Lamine, FlashDreams OHG # # [url="http://www.flashdreams.de/"]http://www.flashdreams.de/[/url] # # # # Modified by [url="http://www.tse.at"]http://www.tse.at[/url] # # Modified by [email protected] # # # # This script may be freely used, distributed # # and modified without any charge as long as # # this copyright information is included. # # # # Any commercial selling of this script is # # forbidden. # # # # The author is not responsible for possible # # damage which may result from the application # # of this script, neither direct nor indirect. # # Use at your own risk! # ##############################################*/ error_reporting(0); $types = array (1 => "gif", "jpeg", "png"); // Formats Not Supported - To use this feature uncomment the line below // (beginning with ($not_supported_formats) and add the files types you do not // want thumbed. // $not_supported_formats = array ("GIF"); // Write in capital Letters!! umask(0); !is_dir ($cachedir) ? mkdir ($cachedir, 0777) : system ("chmod 0777 ".$cachedir); (!isset ($x) || ereg ('^[0-9]{1,}$', $x, $regs)) && (!isset ($y) || ereg ('^[0-9]{1,}$', $y, $regs)) && (isset ($x) || isset ($y)) ? true : DIE ('Fehlende® oder ungültige® Größenparameter!'); !isset ($resize) || !ereg ('^[0|1]$', $resize, $regs) ? $resize = 0 : $resize; !isset ($aspectratio) || !ereg ('^[0|1]$', $aspectratio, $regs) ? isset ($x) && isset ($y) ? $aspectratio = 1 : $aspectratio = 0 : $aspectratio; !isset ($image) ? DIE ('Es wurde kein Bild angegeben!') : !file_exists($image) ? DIE ('Die angegebene Datei konnte nicht auf dem Server gefunden werden!') : false; $imagedata = getimagesize($image); !$imagedata[2] || $imagedata[2] == 4 || $imagedata[2] == 5 ? DIE ('Bei der angegebenen Datei handelt es sich nicht um ein Bild!') : false; $imgtype="!(ImageTypes() & IMG_" . strtoupper($types[$imagedata[2]]) . ")"; if ((eval($imgtype)) || (in_array(strtoupper(array_pop(explode('.', basename($image)))),$not_supported_formats))) { $image = substr ($image, (strrpos (DIR_FS_CATALOG . '/', '/'))+1); return $image; } if (!isset ($x)) $x = floor ($y * $imagedata[0] / $imagedata[1]); if (!isset ($y)) $y = floor ($x * $imagedata[1] / $imagedata[0]); if ($aspectratio && isset ($x) && isset ($y)) { if ((($imagedata[1]/$y) > ($imagedata[0]/$x) )){ $x=ceil(($imagedata[0]/$imagedata[1])* $y); } else { $y=ceil($x/($imagedata[0]/$imagedata[1])); } } $thumbfile = '/'.$x.'x'.$y.'_'. basename($image); if (file_exists ($cachedir.$thumbfile)) { $thumbdata = getimagesize ($cachedir.$thumbfile); $thumbdata[0] == $x && $thumbdata[1] == $y ? $iscached = true : $iscached = false; if (@filemtime($cachedir.$thumbfile) < @filemtime($image)) $iscached = false; } else { $iscached = false; } if (!$iscached) { ($imagedata[0] > $x || $imagedata[1] > $y) || (($imagedata[0] < $x || $imagedata[1] < $y) && $resize) ? $makethumb = true : $makethumb = false; } else { $makethumb = false; } if ($makethumb) { $image = call_user_func("imagecreatefrom".$types[$imagedata[2]], $image); if (function_exists("imagecreatetruecolor") && ($thumb = imagecreatetruecolor ($x, $y))) { imagecopyresampled ($thumb, $image, 0, 0, 0, 0, $x, $y, $imagedata[0], $imagedata[1]); } else { $thumb = imagecreate ($x, $y); imagecopyresized ($thumb, $image, 0, 0, 0, 0, $x, $y, $imagedata[0], $imagedata[1]); } call_user_func("image".$types[$imagedata[2]], $thumb, $cachedir.$thumbfile, JPEGQUALITY); imagedestroy ($image); imagedestroy ($thumb); $image = DIR_WS_IMAGES . 'thumbs_cache' . $thumbfile; } else { $iscached ? $image = DIR_WS_IMAGES . 'thumbs_cache' . $thumbfile : $image = substr ($image, (strrpos (DIR_FS_CATALOG . '/', '/'))+1); } return $image; }
Pektsekye Posted June 3, 2009 Posted June 3, 2009 Anyone? Should I offer a reward or something? Hello, any reward or payment offers are not allowed on this forum . as I know first try to replace if ((CONFIG_CALCULATE_IMAGE_SIZE == 'true' && $src != DIR_WS_IMAGES . 'pixel_black.gif' && $src != DIR_WS_IMAGES . 'pixel_trans.gif' && $src != DIR_WS_IMAGES . 'pixel_silver.gif' )) { with if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) { if this doesn't help have look there are images that are excluded : if ((CONFIG_CALCULATE_IMAGE_SIZE == 'true' && $src != DIR_WS_IMAGES . 'pixel_black.gif' && $src != DIR_WS_IMAGES . 'pixel_trans.gif' && $src != DIR_WS_IMAGES . 'pixel_silver.gif' )) { you should add your images for exclusion or add checking by width and height if it is formating(design) image to exclude it: if (($width > 50 && $height > 50 && CONFIG_CALCULATE_IMAGE_SIZE == 'true' && $src != DIR_WS_IMAGES . 'pixel_black.gif' && $src != DIR_WS_IMAGES . 'pixel_trans.gif' && $src != DIR_WS_IMAGES . 'pixel_silver.gif' )) { If this doesn't help show the html sources of the two pages to compare here instead of the screenshots Stanislav
Recommended Posts
Archived
This topic is now archived and is closed to further replies.