diff --git a/assets/img/options/discuss.png b/assets/img/options/discuss.png index bedb32b..ab4c4b8 100644 Binary files a/assets/img/options/discuss.png and b/assets/img/options/discuss.png differ diff --git a/inc/options-framework/js/options-custom.js b/inc/options-framework/js/options-custom.js index 3389f66..6dde1ce 100755 --- a/inc/options-framework/js/options-custom.js +++ b/inc/options-framework/js/options-custom.js @@ -48,6 +48,7 @@ jQuery(document).ready(function ($) { jQuery("#section-g_imgx_serviceid").fadeToggle(400); jQuery("#section-g_imgx_region").fadeToggle(400); jQuery("#section-g_imgx_url").fadeToggle(400); + jQuery("#section-g_imgx_tmp").fadeToggle(400); jQuery("#section-g_imgx_accesskey").fadeToggle(400); jQuery("#section-g_imgx_secretkey").fadeToggle(400); }); @@ -56,6 +57,7 @@ jQuery(document).ready(function ($) { jQuery("#section-g_imgx_serviceid").show(); jQuery("#section-g_imgx_region").show(); jQuery("#section-g_imgx_url").show(); + jQuery("#section-g_imgx_tmp").show(); jQuery("#section-g_imgx_accesskey").show(); jQuery("#section-g_imgx_secretkey").show(); } diff --git a/inc/theme-options.php b/inc/theme-options.php index c37ea76..d921181 100644 --- a/inc/theme-options.php +++ b/inc/theme-options.php @@ -3,7 +3,7 @@ * 主题选项 * @author Seaton Jiang * @license MIT License - * @version 2021.05.22 + * @version 2021.06.17 */ function getrobots() @@ -54,6 +54,10 @@ function kratos_options() $seorobots = 'robots.txt'; $seoreading = '' . __('设置-阅读-对搜索引擎的可见性', 'kratos') . ''; + $imgxconsole = '火山引擎控制台'; + $imgxtmp = '图片处理配置'; + $imgxsid = '图片服务管理'; + $cc_array = array( 'one' => __('知识共享署名 4.0 国际许可协议', 'kratos'), 'two' => __('知识共享署名-非商业性使用 4.0 国际许可协议', 'kratos'), @@ -254,6 +258,7 @@ function kratos_options() $options[] = array( 'name' => __('服务ID', 'kratos'), 'id' => 'g_imgx_serviceid', + 'desc' => __('服务ID在控制台', 'kratos') . $imgxsid . __('中获取', 'kratos'), 'class' => 'hidden', 'type' => 'text', ); @@ -261,14 +266,24 @@ function kratos_options() $options[] = array( 'name' => __('加速域名', 'kratos'), 'id' => 'g_imgx_url', + 'desc' => __('最后不要添加 /', 'kratos'), 'placeholder' => __('例如:https://cdn.xxx.com', 'kratos'), 'class' => 'hidden', 'type' => 'text', ); + $options[] = array( + 'name' => __('图片处理模板', 'kratos'), + 'id' => 'g_imgx_tmp', + 'desc' => __('模板配置代码在控制台', 'kratos') . $imgxtmp . __('中获取', 'kratos'), + 'class' => 'hidden', + 'type' => 'text', + ); + $options[] = array( 'name' => __('AccessKey', 'kratos'), 'id' => 'g_imgx_accesskey', + 'desc' => __('AccessKey 在', 'kratos') . $imgxconsole . __('中获取', 'kratos'), 'class' => 'hidden', 'type' => 'password', ); @@ -276,6 +291,7 @@ function kratos_options() $options[] = array( 'name' => __('SecretKey', 'kratos'), 'id' => 'g_imgx_secretkey', + 'desc' => __('SecretKey 在', 'kratos') . $imgxconsole . __('中获取', 'kratos'), 'class' => 'hidden', 'type' => 'password', ); diff --git a/inc/theme-volcengine.php b/inc/theme-volcengine.php index 862fdda..4bcba62 100644 --- a/inc/theme-volcengine.php +++ b/inc/theme-volcengine.php @@ -3,7 +3,7 @@ * ImageX 图片服务 * @author Seaton Jiang * @license MIT License - * @version 2021.06.05 + * @version 2021.06.17 */ require_once 'volcengine-imagex/vendor/autoload.php'; @@ -128,4 +128,30 @@ if (kratos_option('g_imgx', false)) { return $uploads; } add_filter('upload_dir', 'custom_upload_dir'); + + function imagex_setting_content_ci($content) + { + preg_match_all('//sim', $content, $images); + if (!empty($images) && isset($images[1])) { + foreach ($images[1] as $item) { + $content = str_replace($item, $item . kratos_option('g_imgx_tmp'), $content); + } + } + return $content; + } + add_filter('the_content', 'imagex_setting_content_ci'); + + function imagex_setting_post_thumbnail_ci($html, $post_id, $post_image_id) + { + if (has_post_thumbnail()) { + preg_match_all('//sim', $html, $images); + if (!empty($images) && isset($images[1])) { + foreach ($images[1] as $item) { + $html = str_replace($item, $item . kratos_option('g_imgx_tmp'), $html); + } + } + } + return $html; + } + add_filter('post_thumbnail_html', 'imagex_setting_post_thumbnail_ci', 10, 3); } \ No newline at end of file