From 00660e87557094553f8525cab66d7e80a10183eb Mon Sep 17 00:00:00 2001 From: Seaton Jiang Date: Tue, 17 Mar 2020 10:24:12 +0800 Subject: [PATCH] feat: add thumbnail control --- inc/theme-core.php | 19 ++++++++++++++++--- inc/theme-options.php | 10 +++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/inc/theme-core.php b/inc/theme-core.php index f9457cb..855f369 100644 --- a/inc/theme-core.php +++ b/inc/theme-core.php @@ -3,7 +3,7 @@ * 核心函数 * @author Seaton Jiang * @license MIT License - * @version 2020.02.15 + * @version 2020.03.17 */ // 自动跳转主题设置 @@ -42,7 +42,7 @@ function theme_autoload() wp_enqueue_style('bootstrap', $dir . '/assets/css/bootstrap.min.css', array(), '4.4.1'); wp_enqueue_style('kicon', $dir . '/assets/css/iconfont.min.css', array(), THEME_VERSION); wp_enqueue_style('layer', $dir . '/assets/css/layer.min.css', array(), '3.1.1'); - if(kratos_option('g_animate',false)){ + if (kratos_option('g_animate', false)) { wp_enqueue_style('animate', $dir . '/assets/css/animate.min.css', array(), '3.7.2'); } wp_enqueue_style('kratos', $dir . '/assets/css/kratos.min.css', array(), THEME_VERSION); @@ -167,4 +167,17 @@ $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker( 'https://github.com/Vtrois/Kratos/', get_template_directory() . '/functions.php', 'Kratos' -); \ No newline at end of file +); + +// 禁止生成多种尺寸图片 +if (kratos_option('g_removeimgsize', false)) { + function remove_default_images($sizes) + { + unset($sizes['thumbnail']); + unset($sizes['medium']); + unset($sizes['large']); + unset($sizes['medium_large']); + return $sizes; + } + add_filter('intermediate_image_sizes_advanced', 'remove_default_images'); +} \ No newline at end of file diff --git a/inc/theme-options.php b/inc/theme-options.php index 7780852..fb0a063 100644 --- a/inc/theme-options.php +++ b/inc/theme-options.php @@ -3,7 +3,7 @@ * 主题选项 * @author Seaton Jiang * @license MIT License - * @version 2020.02.26 + * @version 2020.03.17 */ function getrobots() @@ -100,6 +100,14 @@ function kratos_options() 'options' => $cdn_array, ); + $options[] = array( + 'name' => __('禁止生成缩略图', 'kratos'), + 'desc' => __('是否禁止生成多种尺寸图片资源', 'kratos'), + 'id' => 'g_removeimgsize', + 'std' => '0', + 'type' => 'checkbox', + ); + $options[] = array( 'name' => __('Gutenberg 编辑器', 'kratos'), 'desc' => __('开启 Gutenberg 编辑器', 'kratos'),