diff --git a/conf/app.php b/conf/app.php index 8ab7bfa..6d4f8b3 100644 --- a/conf/app.php +++ b/conf/app.php @@ -130,6 +130,9 @@ $configs = array( 'service_3rd_api_key' => '你的密钥', 'sms_code_cache_time' => 600, //短信验证码缓存时长,单位:秒 + //图片cdn加速域名配置 + 'img_cdn_budget_url' => '', + //Google Analytics MEASUREMENT ID 'GA_MEASUREMENT_ID' => 'G-09MWT3Z9R0', diff --git a/plugins/Html.php b/plugins/Html.php index d67f778..08523ce 100644 --- a/plugins/Html.php +++ b/plugins/Html.php @@ -120,4 +120,14 @@ eof; return $tmp_arr; } + //获取用户图片的cdn地址 + public static function getCDNImageUrl($localImgUrl) { + if (!empty(FSC::$app['config']['debug'])) {return $localImgUrl;} + + $cdn = FSC::$app['config']['img_cdn_budget_url']; + if (empty($cdn)) {return $localImgUrl;} + + return "{$cdn}{$localImgUrl}"; + } + } diff --git a/themes/tajian/views/my/favs.php b/themes/tajian/views/my/favs.php index 8758d25..6c376c1 100644 --- a/themes/tajian/views/my/favs.php +++ b/themes/tajian/views/my/favs.php @@ -47,7 +47,7 @@ $allTags = Html::getTagNames($viewData['tags']); continue; } - $snapshot = !empty($file['cover']) ? $imgPreffix . $file['cover'] : '/img/default.png'; + $snapshot = !empty($file['cover']) ? Html::getCDNImageUrl($imgPreffix . $file['cover']) : '/img/default.png'; $title = !empty($file['title']) ? Html::mb_substr($file['title'], 0, 33, 'utf-8') : $file['filename']; $platform = Html::getShareVideosPlatform($file['shortcut']['url']); diff --git a/themes/tajian/views/site/index.php b/themes/tajian/views/site/index.php index 0637019..e21df94 100644 --- a/themes/tajian/views/site/index.php +++ b/themes/tajian/views/site/index.php @@ -56,7 +56,7 @@ eof; continue; } - $snapshot = !empty($file['cover']) ? $imgPreffix . $file['cover'] : '/img/default.png'; + $snapshot = !empty($file['cover']) ? Html::getCDNImageUrl($imgPreffix . $file['cover']) : '/img/default.png'; $title = !empty($file['title']) ? Html::mb_substr($file['title'], 0, 33, 'utf-8') : $file['filename']; $platform = Html::getShareVideosPlatform($file['shortcut']['url']);