Skip to content

Commit

Permalink
[Imp] Use field to customize the picture
Browse files Browse the repository at this point in the history
  • Loading branch information
idawnlight committed Oct 21, 2017
1 parent 66fdaa1 commit 7607ab1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<p style="font-size:14px;" id="use-intro">
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7607ab1

Please sign in to comment.