From 7607ab1bd9ad528dbf33ab86f6ce98e520e65a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=98=8E=E4=BD=99=E5=85=89?= Date: Sat, 21 Oct 2017 19:59:01 +0800 Subject: [PATCH] [Imp] Use field to customize the picture --- functions.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/functions.php b/functions.php index 52549b7..7d8569f 100644 --- a/functions.php +++ b/functions.php @@ -36,6 +36,10 @@ function themeInit($archive) /** * 主题设置 */ +function themeFields($layout) { + $picUrl = new Typecho_Widget_Helper_Form_Element_Text('picUrl', NULL, NULL, _t('图片地址'), _t('在这里填入一个图片 URL 地址, 作为文章的头图')); + $layout->addItem($picUrl); +} function themeConfig($form) { echo '

@@ -308,6 +312,11 @@ function themeConfig($form) */ function showThumbnail($widget) { + if($widget->fields->picUrl){ + echo $widget->fields->picUrl; + return; + } + //If article no include picture, display random default picture $rand = rand(1, $widget->widget('Widget_Options')->RandomPicAmnt); //Random number