lazyload options

pull/121/head
root 2019-10-25 13:00:27 +00:00
parent 425348bb8f
commit cd60df83ff
4 changed files with 24 additions and 8 deletions

View File

@ -13,7 +13,7 @@
两位前辈做得已经很棒了,或许我所做的只是把他们的代码弄得凌乱不堪吧 :)
注意:建议 `git clone` 下载([简易 Git 使用指南](https://github.com/mashirozx/Sakura/wiki/Git-%E4%B8%8B%E8%BD%BD%E3%80%81%E6%9B%B4%E6%96%B0%E6%8C%87%E5%8D%97));如果选择下载压缩包,解压后记得把文件夹名改回 `Sakura`,也即保证主题路径为 `/wp-content/themes/Sakura/`;请留意主题说明里的其他注意事项。
注意:建议 `git clone` 下载([简易 Git 使用指南](https://github.com/mashirozx/Sakura/wiki/Git-%E4%B8%8B%E8%BD%BD%E3%80%81%E6%9B%B4%E6%96%B0%E6%8C%87%E5%8D%97));如果选择下载压缩包,**解压后记得把文件夹名改回 `Sakura`,也即保证主题路径为 `/wp-content/themes/Sakura/`**;主题设置在 `菜单-外观-Sakura设置`DIY 的时候建议采用[子主题](https://github.com/mashirozx/Sakura/tree/child) 并勾选 `主题设置-CDN-本地调用主题 js、css 文件`;请留意主题说明里的其他注意事项。
主题使用说明见:<https://2heng.xin/theme-sakura/>

View File

@ -1513,12 +1513,14 @@ function codecheese_register_post( $sanitized_user_login, $user_email, $errors )
// html 标签处理器
function html_tag_parser($content) {
if(!is_feed()) {
$content=preg_replace(
'/<img(.+)src=[\'"]([^\'"]+)[\'"](.*)>/i',
"<img $1 class=\"lazyload\" data-src=\"$2\" src=\"https://cdn.jsdelivr.net/gh/moezx/cdn@3.0.2/img/svg/loader/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\" $3 >\n<noscript>$0</noscript>",
$content
);
if(!is_feed()) {
if(akina_option('lazyload') && akina_option('lazyload_spinner')){
$content=preg_replace(
'/<img(.+)src=[\'"]([^\'"]+)[\'"](.*)>/i',
"<img $1 class=\"lazyload\" data-src=\"$2\" src=\"".akina_option('lazyload_spinner')."\" onerror=\"imgError(this)\" $3 >\n<noscript>$0</noscript>",
$content
);
}
//Fancybox
/* Markdown Regex Pattern for Matching URLs:

View File

@ -1027,6 +1027,20 @@ function optionsframework_options() {
'std' => '0',
'type' => 'checkbox');
$options[] = array(
'name' => __('文章内图片启用 lazyload', 'options_framework_theme'),
'desc' => __('默认启用', 'options_framework_theme'),
'id' => 'lazyload',
'std' => '1',
'type' => 'checkbox');
$options[] = array(
'name' => __('lazyload spinner', 'options_framework_theme'),
'desc' => __('图片加载时要显示的占位图,填写图片 url', 'options_framework_theme'),
'id' => 'lazyload_spinner',
'std' => 'https://cdn.jsdelivr.net/gh/moezx/cdn@3.0.2/img/svg/loader/trans.ajax-spinner-preloader.svg',
'type' => 'text');
$options[] = array(
'name' => __('是否开启剪贴板版权标识', 'options_framework_theme'),
'desc' => __('复制超过30个字节时自动向剪贴板添加版权标识默认开启', 'options_framework_theme'),

View File

@ -8,7 +8,7 @@ Description: Akina主题分支原版地址 http://www.akina.pw/themeakina
Version: 3.2.7
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: akina
Text Domain: Sakura
Tags:
*/