Spice Posted January 20, 2004 Share Posted January 20, 2004 Hello I just installed a Automatic thumbnail creator on my site. And now all thumbs are gone but the enlargements work. My catalog aint named Catalog. This is what I added and did: My "catalog" is names shop what should I do? ************************************************************** This is an automatic Thumbnail creator. Each picture in your Shop will be chached in the "/catalog/images/imagecache" directory in the right size and with the same name as the original. The size is set in the Admin panel under Configuration - Images. These values are the max values. The thumbnail will be created in the right proportions. The tumbnail will be created an th first time the picture is call in the Shop. Once an thumbnail is created it will always be used until you change the size in the Admin panel. If you delete an image, you have also to delete the thumbnail in the "/catalog/images/imagecache" directory manually Have fun! Installing should be quite easy, only one file tho change. Follow these 7 steps: 1. Open the File: /catalog/includes/functions/html_output.php 2. Search for: (~ Line 73) //// // The HTML image wrapper function function tep_image($src, $alt = '', $width = '', $height = '', $params = '') { if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) { return ''; } 3. Insert the following after it: if ($image_size = @getimagesize($src)) { if ((CONFIG_CALCULATE_IMAGE_SIZE == 'true')) { 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 . 'imagecache'); 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 ''; } 4. Search for this and delete it: 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; } } 5. Go to the bottom of the File and insert before the ?> if your Webspace has GIF read and write ability delete GIF in the following text at $not_supported_formats = array ("GIF"); // Write in capital Letters!! function thumbimage ($image, $x, $y, $aspectratio, $resize, $cachedir){ /*############################################## # - Thumbnail-Script v1.3 - # # Generating thumbnails 'on-the-fly' with PHP # # # # © by Christian Lamine, FlashDreams OHG # # http://www.flashdreams.de/ # # # # Modified by http://www.tse.at # # # # 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", "swf", "psd", "wbmp"); $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 = '/' . basename($image); if (file_exists ($cachedir.$thumbfile)) { $thumbdata = getimagesize ($cachedir.$thumbfile); $thumbdata[0] == $x && $thumbdata[1] == $y ? $iscached = true : $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); $thumb = imagecreatetruecolor ($x, $y); imagecopyresampled ($thumb, $image, 0, 0, 0, 0, $x, $y, $imagedata[0], $imagedata[1]); call_user_func("image".$types[$imagedata[2]], $thumb, $cachedir.$thumbfile); imagedestroy ($image); imagedestroy ($thumb); $image = DIR_WS_IMAGES . 'imagecache' . $thumbfile; } else { $iscached ? $image = DIR_WS_IMAGES . 'imagecache' . $thumbfile : $image = substr ($image, (strrpos (DIR_FS_CATALOG . '/', '/'))+1); } return $image; } 7 Thats it - enjoy! Link to comment Share on other sites More sharing options...
Spice Posted January 20, 2004 Author Share Posted January 20, 2004 I did take my old file and uploaded it again. I'll try and find a better automatic thumbnail creator. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.