当前位置: 首页>>代码示例>>PHP>>正文


PHP phpThumb::GenerateCachedFilename方法代码示例

本文整理汇总了PHP中phpThumb::GenerateCachedFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP phpThumb::GenerateCachedFilename方法的具体用法?PHP phpThumb::GenerateCachedFilename怎么用?PHP phpThumb::GenerateCachedFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpThumb的用法示例。


在下文中一共展示了phpThumb::GenerateCachedFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: phpThumb

 /**
  *	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;
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:59,代码来源:YDFileSystem.php

示例2: header

        $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';
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:31,代码来源:phpThumb.php


注:本文中的phpThumb::GenerateCachedFilename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。