diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index c1a5d4807..b155ae2fc 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -571,7 +571,7 @@ class e107 $ret['CACHE_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'cache/'; $ret['CACHE_CONTENT_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'content/'; - $ret['CACHE_IMAGE_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'images/'; + $ret['CACHE_IMAGE_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'images/'; //TODO Change to MEDIA Directory. $ret['CACHE_DB_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'db/'; $ret['CACHE_URL_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'url/'; diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 883583aa1..88d4c7803 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -2487,6 +2487,51 @@ class e_parse extends e_parser } + /** + * Generated a Thumb Cache File Name from path and options. + * @param string $path + * @param array $options + * @return null|string + */ + public function thumbCacheFile($path, $options=array()) + { + if(empty($path)) + { + return null; + } + + $filename = basename($path); + $tmp = explode('.',$filename); + $ext = end($tmp); + $len = strlen($ext) + 1; + $start = substr($filename,0,- $len); + + if(!empty($options['aw'])) + { + $options['w'] = $options['aw']; + } + + if(!empty($options['ah'])) + { + $options['h'] = $options['ah']; + } + + $size = varset($options['w'],0).'x'.varset($options['h'],0); + + $thumbQuality = e107::getPref('thumbnail_quality',65); + + $cache_str = md5(serialize($options).$path. $thumbQuality); + + // TODO Remove these. + $pre = 'thumb_'; + $post = '.cache.bin'; + // $post = ''; + + $fname = $pre.strtolower($start.'_'.$cache_str.'_'.$size.'.'.$ext).$post; + + return $fname; + } + /** * Generate an auto-sized Image URL. diff --git a/thumb.php b/thumb.php index f35281ea1..017315663 100644 --- a/thumb.php +++ b/thumb.php @@ -264,10 +264,10 @@ class e_thumbpage // return false; } - $cache_str = md5(serialize($options). $this->_src_path. $this->_thumbQuality. $options['c']); - $fname = strtolower('Thumb_'.$thumbnfo['filename'].'_'.$cache_str.'.'.$thumbnfo['extension']).'.cache.bin'; - + // $cache_str = md5(serialize($options). $this->_src_path. $this->_thumbQuality); + // $fname = strtolower('Thumb_'.$thumbnfo['filename'].'_'.$cache_str.'.'.$thumbnfo['extension']).'.cache.bin'; + $fname = e107::getParser()->thumbCacheFile($this->_src_path, $options); if(($this->_cache === true) && is_file(e_CACHE_IMAGE.$fname) && is_readable(e_CACHE_IMAGE.$fname) && ($this->_debug !== true)) {