|
|
@ -590,6 +590,7 @@ Class SiteController extends Controller { |
|
|
|
//优先从缓存获取小尺寸的图片 |
|
|
|
//优先从缓存获取小尺寸的图片 |
|
|
|
//增加父目录封面图缓存更新 |
|
|
|
//增加父目录封面图缓存更新 |
|
|
|
//增加图片尺寸类型参数: size |
|
|
|
//增加图片尺寸类型参数: size |
|
|
|
|
|
|
|
//增加缩略图生成失败检查,如果缩略图文件大小小于 5 Kb,则认为生成了无效的图片(如黑图) |
|
|
|
public function actionSmallimg() { |
|
|
|
public function actionSmallimg() { |
|
|
|
$imgId = $this->get('id', ''); |
|
|
|
$imgId = $this->get('id', ''); |
|
|
|
$imgUrl = $this->get('url', ''); |
|
|
|
$imgUrl = $this->get('url', ''); |
|
|
@ -605,6 +606,17 @@ Class SiteController extends Controller { |
|
|
|
|
|
|
|
|
|
|
|
$small_image_client_cache_seconds = FSC::$app['config']['small_image_client_cache_seconds']; |
|
|
|
$small_image_client_cache_seconds = FSC::$app['config']['small_image_client_cache_seconds']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//检查文件大小,如果小于 5 Kb,则重新生成图片 |
|
|
|
|
|
|
|
if (!empty($cachedData)) { |
|
|
|
|
|
|
|
$imgType = preg_replace('/^data:(image\/.+);base64,.+$/i', "$1", $cachedData); |
|
|
|
|
|
|
|
$base64_img = preg_replace('/^data:image\/.+;base64,/i', '', $cachedData); |
|
|
|
|
|
|
|
$img_data = base64_decode($base64_img); |
|
|
|
|
|
|
|
$minNormalImgSize = 5 * 1024; //最小图片尺寸:5Kb |
|
|
|
|
|
|
|
if (strlen($img_data) < $minNormalImgSize) { |
|
|
|
|
|
|
|
$cachedData = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//无缓存,则实时生成缩略图 |
|
|
|
//无缓存,则实时生成缩略图 |
|
|
|
if (empty($cachedData)) { |
|
|
|
if (empty($cachedData)) { |
|
|
|
$tmpUrl = parse_url($imgUrl); |
|
|
|
$tmpUrl = parse_url($imgUrl); |
|
|
@ -629,7 +641,6 @@ Class SiteController extends Controller { |
|
|
|
$base64_img = preg_replace('/^data:image\/.+;base64,/i', '', $cachedData); |
|
|
|
$base64_img = preg_replace('/^data:image\/.+;base64,/i', '', $cachedData); |
|
|
|
|
|
|
|
|
|
|
|
$img_data = base64_decode($base64_img); |
|
|
|
$img_data = base64_decode($base64_img); |
|
|
|
|
|
|
|
|
|
|
|
$etag = md5($img_data); |
|
|
|
$etag = md5($img_data); |
|
|
|
$etag_from_client = !empty($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : ''; //get etag from client |
|
|
|
$etag_from_client = !empty($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : ''; //get etag from client |
|
|
|
if (!empty($etag) && $etag == $etag_from_client) { |
|
|
|
if (!empty($etag) && $etag == $etag_from_client) { |
|
|
|