|
|
@ -270,7 +270,7 @@ Class SiteController extends Controller { |
|
|
|
|
|
|
|
|
|
|
|
if (empty($cachedData)) { |
|
|
|
if (empty($cachedData)) { |
|
|
|
//从缓存数据中获取目录的realpath |
|
|
|
//从缓存数据中获取目录的realpath |
|
|
|
$cachedData = Common::getCacheFromFile($cacheId); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheId, $expireSeconds); |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
|
$realpath = $cachedData[$cateId]['realpath']; |
|
|
|
$realpath = $cachedData[$cateId]['realpath']; |
|
|
|
$scanner = new DirScanner(); |
|
|
|
$scanner = new DirScanner(); |
|
|
@ -374,15 +374,23 @@ Class SiteController extends Controller { |
|
|
|
list($naturalWidth, $naturalHeight, $imgTypeIndex, $style) = getimagesize($img_filepath); |
|
|
|
list($naturalWidth, $naturalHeight, $imgTypeIndex, $style) = getimagesize($img_filepath); |
|
|
|
$imgType = image_type_to_extension($imgTypeIndex); |
|
|
|
$imgType = image_type_to_extension($imgTypeIndex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//小图片则保持原图尺寸 |
|
|
|
|
|
|
|
if ($naturalWidth <= $max_width || $naturalHeight <= $max_height) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//生成同比例缩略图尺寸 |
|
|
|
//生成同比例缩略图尺寸 |
|
|
|
|
|
|
|
$zoomRate = FSC::$app['config']['small_image_zoom_rate']; //缩略图在最小尺寸基础上放大比例,为确保清晰度 |
|
|
|
$width = $min_width; |
|
|
|
$width = $min_width; |
|
|
|
$height = $min_height; |
|
|
|
$height = $min_height; |
|
|
|
$aspect = $naturalHeight / $naturalWidth; |
|
|
|
$aspect = $naturalHeight / $naturalWidth; |
|
|
|
if ($naturalWidth <= $naturalHeight) { |
|
|
|
if ($naturalWidth <= $naturalHeight) { |
|
|
|
$width = $width * 2.5 <= $max_width ? (int)($width * 2.5) : $max_width; |
|
|
|
if ($width * $zoomRate >= $naturalWidth) {return false;} //避免把小图片放大 |
|
|
|
|
|
|
|
$width = $width * $zoomRate <= $max_width ? (int)($width * $zoomRate) : $max_width; |
|
|
|
$height = (int)($width * $aspect); |
|
|
|
$height = (int)($width * $aspect); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$height = $height * 2.5 <= $max_height ? (int)($height * 2.5) : $max_height; |
|
|
|
if ($height * $zoomRate >= $naturalHeight) {return false;} //避免把小图片放大 |
|
|
|
|
|
|
|
$height = $height * $zoomRate <= $max_height ? (int)($height * $zoomRate) : $max_height; |
|
|
|
$width = (int)($height / $aspect); |
|
|
|
$width = (int)($height / $aspect); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|