Skip to content

Commit

Permalink
🖼 Add: 后台可自定义文章随机图
Browse files Browse the repository at this point in the history
  • Loading branch information
BigCoke233 authored Mar 20, 2020
1 parent 7cbfae7 commit 6738d38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @package Miracles
* @author Eltrac
* @version 1.4.1
* @version 1.4.2
* @link https://guhub.cn
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand All @@ -22,7 +22,17 @@
<div class="col-md-6 post-banner-box">
<a href="<?php $this->permalink(); ?>" class="post-link">
<div class="post-banner">
<img src="/usr/themes/Miracles/images/loading/<?php echo $this->options->loading_image ?>.gif" data-original="<?php if($this->fields->banner && $this->fields->banner=!''): ?><?php echo $this->fields->banner(); ?><?php else: ?><?php Utils::indexTheme('images/postbg/'); ?><?php echo mt_rand(1,20); ?>.jpg<?php endif; ?>">
<img src="/usr/themes/Miracles/images/loading/<?php echo $this->options->loading_image ?>.gif" data-original="<?php
if($this->fields->banner && $this->fields->banner=!''):
echo $this->fields->banner();
else:
if($this->options->randomBanner==''){
echo Utils::indexTheme('images/postbg/'); echo mt_rand(1,mt_rand(1,20)); echo '.jpg';
}
else{
$banner_url = explode(',',$this->options->randomBanner);
echo $banner_url[mt_rand(0,count($banner_url)-1)];}
endif; ?>">
</div>
</a>
</div>
Expand Down
2 changes: 2 additions & 0 deletions libs/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ function themeConfig($form) {
$form->addInput($grayTheme);
$bodyFonts = new Typecho_Widget_Helper_Form_Element_Select('bodyFonts',array('0'=>'无衬线字体','1'=>'衬线字体'),'0','网站字体','选择网站的字体,无衬线字体即“思源黑体”,衬线字体即“思源宋体”');
$form->addInput($bodyFonts);
$randomBanner = new Typecho_Widget_Helper_Form_Element_Textarea('randomBanner', NULL, NULL, _t('随机文章缩略图'), _t('文章没有独立设置头图时调用,写入图片链接,用半角逗号分割'));
$form->addInput($randomBanner);

//LoadingImage
$LoadingOptions = [
Expand Down

0 comments on commit 6738d38

Please sign in to comment.