diff options
| author | BigCoke233 <hi@guhub.cn> | 2020-07-17 00:15:54 +0800 |
|---|---|---|
| committer | BigCoke233 <hi@guhub.cn> | 2020-07-17 00:15:54 +0800 |
| commit | 2c028cef411a2eae19c82b7b89fedb9b8b191b4f (patch) | |
| tree | 24bac20b76b100acff8db76dd1680a6d196dcd03 /libs/Utils.php | |
| parent | d6fc2cb3f1943a2c118fce837571c1cab9eee952 (diff) | |
🖼️ Perf: 支持用 cdn 加速懒加载图片了
Diffstat (limited to 'libs/Utils.php')
| -rw-r--r-- | libs/Utils.php | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/libs/Utils.php b/libs/Utils.php index 27d7658..397448c 100644 --- a/libs/Utils.php +++ b/libs/Utils.php @@ -135,7 +135,7 @@ class Utils $path = 'https://cdn.9jojo.cn/Miracles/'.themeVersion().'/'; } elseif ($cdn=='3'){ - $path = $custom; + $path = $custom; }else{ $path = Helper::options()->themeUrl("","Miracles/assets"); } @@ -150,6 +150,39 @@ class Utils } /** + * 自动生成懒加载图片 url + */ + public static function addLoadingImages($cdn, $loading_image, $type){ + if ($type=='normal'): + $loading = $loading_image; + elseif($type=='link'): + $loading = 'avatar'; + elseif($type=='owo'): + $loading = 'owo'; + endif; + + if ($cdn=='1' || $cdn=='6'){ + $path = 'https://cdn.jsdelivr.net/gh/BigCoke233/miracles@'.themeVersion()."/images/loading/".$loading.'.gif'; + } + elseif ($cdn=='2'){ + $path = 'https://raw.githack.com/BigCoke233/miracles/master/images/loading/'.$loading.'.gif'; + } + elseif ($cdn=='4'){ + $path = 'https://rawcdn.githack.com/BigCoke233/miracles/master/images/loading/'.$loading.'.gif'; + } + elseif ($cdn=='5'){ + //9jojo CDN 并未提供图片缓存 则换用 jsDelivr + $path = 'https://cdn.jsdelivr.net/gh/BigCoke233/miracles@'.themeVersion()."/images/loading/".$loading.'.gif'; + } + elseif ($cdn=='3'){ + $path = $custom; + }else{ + $path = Helper::options()->themeUrl("","Miracles/images/loading").$loading.'.gif'; + } + return $path; + } + + /** * 缩略图 */ public static function postBanner($post){ |
