本文整理汇总了PHP中phpThumb::SetCacheFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP phpThumb::SetCacheFilename方法的具体用法?PHP phpThumb::SetCacheFilename怎么用?PHP phpThumb::SetCacheFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpThumb
的用法示例。
在下文中一共展示了phpThumb::SetCacheFilename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: spit_phpthumb_image
function spit_phpthumb_image($filepath, $configarray = array())
{
// set up class
global $CFG, $PHPTHUMB_CONFIG;
$phpThumb = new phpThumb();
// import default config
if (!empty($PHPTHUMB_CONFIG)) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_' . $key;
$phpThumb->setParameter($keyname, $value);
}
}
// import passed params
if (!empty($configarray)) {
foreach ($configarray as $key => $value) {
$keyname = $key;
$phpThumb->setParameter($keyname, $value);
}
}
$phpThumb->setSourceFilename($filepath);
if (!is_file($phpThumb->sourceFilename) && !phpthumb_functions::gd_version()) {
if (!headers_sent()) {
// base64-encoded error image in GIF format
$ERROR_NOGD = 'R0lGODlhIAAgALMAAAAAABQUFCQkJDY2NkZGRldXV2ZmZnJycoaGhpSUlKWlpbe3t8XFxdXV1eTk5P7+/iwAAAAAIAAgAAAE/vDJSau9WILtTAACUinDNijZtAHfCojS4W5H+qxD8xibIDE9h0OwWaRWDIljJSkUJYsN4bihMB8th3IToAKs1VtYM75cyV8sZ8vygtOE5yMKmGbO4jRdICQCjHdlZzwzNW4qZSQmKDaNjhUMBX4BBAlmMywFSRWEmAI6b5gAlhNxokGhooAIK5o/pi9vEw4Lfj4OLTAUpj6IabMtCwlSFw0DCKBoFqwAB04AjI54PyZ+yY3TD0ss2YcVmN/gvpcu4TOyFivWqYJlbAHPpOntvxNAACcmGHjZzAZqzSzcq5fNjxFmAFw9iFRunD1epU6tsIPmFCAJnWYE0FURk7wJDA0MTKpEzoWAAskiAAA7';
header('Content-Type: image/gif');
echo base64_decode($ERROR_NOGD);
} else {
echo '*** ERROR: No PHP-GD support available ***';
}
exit;
}
$phpThumb->SetCacheFilename();
if (!file_exists($phpThumb->cache_filename) && is_writable(dirname($phpThumb->cache_filename))) {
// error_log("generating to cache: " . $phpThumb->cache_filename);
$phpThumb->CleanUpCacheDirectory();
$phpThumb->GenerateThumbnail();
$phpThumb->RenderToFile($phpThumb->cache_filename);
}
if (is_file($phpThumb->cache_filename)) {
// error_log("sending from cache: " . $phpThumb->cache_filename);
if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
$mimetype = phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]);
}
spitfile_with_mtime_check($phpThumb->cache_filename, $mimetype);
} else {
// error_log("phpthumb cache file doesn't exist: " . $phpThumb->cache_filename);
$phpThumb->GenerateThumbnail();
$phpThumb->OutputThumbnail();
exit;
}
}
示例2: header
if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
header('Content-Type: ' . phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]));
} elseif (preg_match('/\\.ico$/i', $phpThumb->cache_filename)) {
header('Content-Type: image/x-icon');
}
if (!@$PHPTHUMB_CONFIG['cache_force_passthru'] && preg_match('/^' . preg_quote($nice_docroot) . '(.*)$/', $nice_cachefile, $matches)) {
header('Location: ' . dirname($matches[1]) . '/' . urlencode(basename($matches[1])));
} else {
@readfile($phpThumb->cache_filename);
}
exit;
}
return true;
}
// check to see if file already exists in cache, and output it with no processing if it does
$phpThumb->SetCacheFilename();
if (@is_file($phpThumb->cache_filename)) {
RedirectToCachedFile();
} else {
$phpThumb->DebugMessage('Cached file "' . $phpThumb->cache_filename . '" does not exist, processing as normal', __FILE__, __LINE__);
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[6]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '6') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
if ($phpThumb->rawImageData) {
// great
} elseif (@$_GET['new']) {
示例3: YDInclude
/**
* 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
YDInclude('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 = $thumb->SetCacheFilename();
$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;
}