mirror of https://github.com/vtrois/kratos
feat: add ImageX template
parent
257b73d75a
commit
d9972d3c72
Binary file not shown.
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 69 KiB |
|
@ -48,6 +48,7 @@ jQuery(document).ready(function ($) {
|
||||||
jQuery("#section-g_imgx_serviceid").fadeToggle(400);
|
jQuery("#section-g_imgx_serviceid").fadeToggle(400);
|
||||||
jQuery("#section-g_imgx_region").fadeToggle(400);
|
jQuery("#section-g_imgx_region").fadeToggle(400);
|
||||||
jQuery("#section-g_imgx_url").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_accesskey").fadeToggle(400);
|
||||||
jQuery("#section-g_imgx_secretkey").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_serviceid").show();
|
||||||
jQuery("#section-g_imgx_region").show();
|
jQuery("#section-g_imgx_region").show();
|
||||||
jQuery("#section-g_imgx_url").show();
|
jQuery("#section-g_imgx_url").show();
|
||||||
|
jQuery("#section-g_imgx_tmp").show();
|
||||||
jQuery("#section-g_imgx_accesskey").show();
|
jQuery("#section-g_imgx_accesskey").show();
|
||||||
jQuery("#section-g_imgx_secretkey").show();
|
jQuery("#section-g_imgx_secretkey").show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* 主题选项
|
* 主题选项
|
||||||
* @author Seaton Jiang <seaton@vtrois.com>
|
* @author Seaton Jiang <seaton@vtrois.com>
|
||||||
* @license MIT License
|
* @license MIT License
|
||||||
* @version 2021.05.22
|
* @version 2021.06.17
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getrobots()
|
function getrobots()
|
||||||
|
@ -54,6 +54,10 @@ function kratos_options()
|
||||||
$seorobots = '<a href="' . home_url() . '/robots.txt" target="_blank">robots.txt</a>';
|
$seorobots = '<a href="' . home_url() . '/robots.txt" target="_blank">robots.txt</a>';
|
||||||
$seoreading = '<a href="' . admin_url('options-reading.php') . '" target="_blank">' . __('设置-阅读-对搜索引擎的可见性', 'kratos') . '</a>';
|
$seoreading = '<a href="' . admin_url('options-reading.php') . '" target="_blank">' . __('设置-阅读-对搜索引擎的可见性', 'kratos') . '</a>';
|
||||||
|
|
||||||
|
$imgxconsole = '<a href="https://console.volcengine.com/iam/keymanage/" target="_blank">火山引擎控制台</a>';
|
||||||
|
$imgxtmp = '<a href="https://console.volcengine.com/imagex/image_template/" target="_blank">图片处理配置</a>';
|
||||||
|
$imgxsid = '<a href="https://console.volcengine.com/imagex/service_manage/" target="_blank">图片服务管理</a>';
|
||||||
|
|
||||||
$cc_array = array(
|
$cc_array = array(
|
||||||
'one' => __('知识共享署名 4.0 国际许可协议', 'kratos'),
|
'one' => __('知识共享署名 4.0 国际许可协议', 'kratos'),
|
||||||
'two' => __('知识共享署名-非商业性使用 4.0 国际许可协议', 'kratos'),
|
'two' => __('知识共享署名-非商业性使用 4.0 国际许可协议', 'kratos'),
|
||||||
|
@ -254,6 +258,7 @@ function kratos_options()
|
||||||
$options[] = array(
|
$options[] = array(
|
||||||
'name' => __('服务ID', 'kratos'),
|
'name' => __('服务ID', 'kratos'),
|
||||||
'id' => 'g_imgx_serviceid',
|
'id' => 'g_imgx_serviceid',
|
||||||
|
'desc' => __('服务ID在控制台', 'kratos') . $imgxsid . __('中获取', 'kratos'),
|
||||||
'class' => 'hidden',
|
'class' => 'hidden',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
);
|
);
|
||||||
|
@ -261,14 +266,24 @@ function kratos_options()
|
||||||
$options[] = array(
|
$options[] = array(
|
||||||
'name' => __('加速域名', 'kratos'),
|
'name' => __('加速域名', 'kratos'),
|
||||||
'id' => 'g_imgx_url',
|
'id' => 'g_imgx_url',
|
||||||
|
'desc' => __('最后不要添加 /', 'kratos'),
|
||||||
'placeholder' => __('例如:https://cdn.xxx.com', 'kratos'),
|
'placeholder' => __('例如:https://cdn.xxx.com', 'kratos'),
|
||||||
'class' => 'hidden',
|
'class' => 'hidden',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$options[] = array(
|
||||||
|
'name' => __('图片处理模板', 'kratos'),
|
||||||
|
'id' => 'g_imgx_tmp',
|
||||||
|
'desc' => __('模板配置代码在控制台', 'kratos') . $imgxtmp . __('中获取', 'kratos'),
|
||||||
|
'class' => 'hidden',
|
||||||
|
'type' => 'text',
|
||||||
|
);
|
||||||
|
|
||||||
$options[] = array(
|
$options[] = array(
|
||||||
'name' => __('AccessKey', 'kratos'),
|
'name' => __('AccessKey', 'kratos'),
|
||||||
'id' => 'g_imgx_accesskey',
|
'id' => 'g_imgx_accesskey',
|
||||||
|
'desc' => __('AccessKey 在', 'kratos') . $imgxconsole . __('中获取', 'kratos'),
|
||||||
'class' => 'hidden',
|
'class' => 'hidden',
|
||||||
'type' => 'password',
|
'type' => 'password',
|
||||||
);
|
);
|
||||||
|
@ -276,6 +291,7 @@ function kratos_options()
|
||||||
$options[] = array(
|
$options[] = array(
|
||||||
'name' => __('SecretKey', 'kratos'),
|
'name' => __('SecretKey', 'kratos'),
|
||||||
'id' => 'g_imgx_secretkey',
|
'id' => 'g_imgx_secretkey',
|
||||||
|
'desc' => __('SecretKey 在', 'kratos') . $imgxconsole . __('中获取', 'kratos'),
|
||||||
'class' => 'hidden',
|
'class' => 'hidden',
|
||||||
'type' => 'password',
|
'type' => 'password',
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* ImageX 图片服务
|
* ImageX 图片服务
|
||||||
* @author Seaton Jiang <seaton@vtrois.com>
|
* @author Seaton Jiang <seaton@vtrois.com>
|
||||||
* @license MIT License
|
* @license MIT License
|
||||||
* @version 2021.06.05
|
* @version 2021.06.17
|
||||||
*/
|
*/
|
||||||
require_once 'volcengine-imagex/vendor/autoload.php';
|
require_once 'volcengine-imagex/vendor/autoload.php';
|
||||||
|
|
||||||
|
@ -128,4 +128,30 @@ if (kratos_option('g_imgx', false)) {
|
||||||
return $uploads;
|
return $uploads;
|
||||||
}
|
}
|
||||||
add_filter('upload_dir', 'custom_upload_dir');
|
add_filter('upload_dir', 'custom_upload_dir');
|
||||||
|
|
||||||
|
function imagex_setting_content_ci($content)
|
||||||
|
{
|
||||||
|
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/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('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/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);
|
||||||
}
|
}
|
Loading…
Reference in New Issue