Browse Source

image add cdn support

master
filesite 6 months ago
parent
commit
dd19f1b395
  1. 3
      conf/app.php
  2. 10
      plugins/Html.php
  3. 2
      themes/tajian/views/my/favs.php
  4. 2
      themes/tajian/views/site/index.php

3
conf/app.php

@ -130,6 +130,9 @@ $configs = array(
'service_3rd_api_key' => '你的密钥', 'service_3rd_api_key' => '你的密钥',
'sms_code_cache_time' => 600, //短信验证码缓存时长,单位:秒 'sms_code_cache_time' => 600, //短信验证码缓存时长,单位:秒
//图片cdn加速域名配置
'img_cdn_budget_url' => '',
//Google Analytics MEASUREMENT ID //Google Analytics MEASUREMENT ID
'GA_MEASUREMENT_ID' => 'G-09MWT3Z9R0', 'GA_MEASUREMENT_ID' => 'G-09MWT3Z9R0',

10
plugins/Html.php

@ -120,4 +120,14 @@ eof;
return $tmp_arr; 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}";
}
} }

2
themes/tajian/views/my/favs.php

@ -47,7 +47,7 @@ $allTags = Html::getTagNames($viewData['tags']);
continue; 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']; $title = !empty($file['title']) ? Html::mb_substr($file['title'], 0, 33, 'utf-8') : $file['filename'];
$platform = Html::getShareVideosPlatform($file['shortcut']['url']); $platform = Html::getShareVideosPlatform($file['shortcut']['url']);

2
themes/tajian/views/site/index.php

@ -56,7 +56,7 @@ eof;
continue; 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']; $title = !empty($file['title']) ? Html::mb_substr($file['title'], 0, 33, 'utf-8') : $file['filename'];
$platform = Html::getShareVideosPlatform($file['shortcut']['url']); $platform = Html::getShareVideosPlatform($file['shortcut']['url']);

Loading…
Cancel
Save