/** * This function will do the actual work of creating a thumbnail image. * * @param $width The maximum width of the thumbnail. * @param $height The maximum height of the thumbnail. * @param $cache (optional) Indicate if the thumbnails should be cached. By default, caching is turned off. * * @internal */ function &_createThumbnail($width, $height, $cache = true) { // Check if the GD library is loaded. if (!extension_loaded('gd')) { $this->_error('YD_gd_not_installed'); } // Include phpThumb require_once 'phpThumb/phpthumb.class.php'; // Create a new thumbnail object $thumb = new phpThumb(); $thumb->src = $this->getAbsolutePath(); // Set the options for the creation of thumbnails $thumb->config_nohotlink_enabled = false; $thumb->config_cache_directory = YD_DIR_TEMP; // Set the width and the height $thumb->w = $width; $thumb->h = $height; // Create the cached thumbnail $cacheFName = $thumb->GenerateCachedFilename(); $cacheFName .= $this->getLastModified(); $cacheFName .= $this->getAbsolutePath(); $cacheFName = YD_TMP_PRE . 'N_' . md5($cacheFName) . '.tmn'; $cacheFName = YD_DIR_TEMP . '/' . $cacheFName; // Check if caching is enabled if ($cache == true) { // Output the cached version if any if (is_file($cacheFName)) { $img = new YDFSImage($cacheFName); header('Content-type: ' . $img->getMimeType()); echo $img->getContents(); die; } } // Width should be positive integer if ($width < 1) { $this->_error(); } // Height should be positive integer if ($width < 1) { $this->_error(); } // Generate the thumbnail $thumb->GenerateThumbnail(); // Check if caching is enabled if ($cache == true) { $thumb->RenderToFile($cacheFName); } // Return the thumbnail object return $thumb; }
$CanPassThroughDirectly = false; break; } } if ($CanPassThroughDirectly && !empty($_REQUEST['src'])) { // no parameters set, passthru $SourceFilename = $phpThumb->ResolveFilenameToAbsolute($_REQUEST['src']); if ($getimagesize = @GetImageSize($SourceFilename)) { header('Content-type: ' . phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2])); @readfile($SourceFilename); exit; } } // check to see if file already exists in cache, and output it with no processing if it does if (!empty($phpThumb->config_cache_directory) && empty($_REQUEST['phpThumbDebug'])) { $cache_filename = $phpThumb->GenerateCachedFilename(); if (is_file($cache_filename)) { header('Content-type: image/' . $phpThumb->thumbnailFormat); @readfile($cache_filename); exit; } } //////////////////////////////////////////////////////////////// // You may want to pull data from a database rather than a physical file // If so, uncomment the following $SQLquery line (modified to suit your database) // Note: this must be the actual binary data of the image, not a URL or filename // see http://www.billy-corgan.com/blog/archive/000143.php for a brief tutorial on this section //$SQLquery = 'SELECT `Picture` FROM `products` WHERE (`ProductID` = \''.mysql_escape_string($_REQUEST['id']).'\')'; if (!empty($SQLquery)) { // change this information to match your server $server = 'localhost';