Posted in

Akina For Typecho主题文章内容页banner图设置为固定图片的教程

按照Akina For Typecho主题默认设置,如果发布的文章里插入了图片,文章banner图会默认调取文章里插入的第一张图片。但是因为插入的图片有大有小,尺寸不一,如若按照默认设置可能会使banner图看起来不搭配,所以我通过如下修改如下代码将banner固定设置为了调取固定图片,即不论文章里是否插入图片,banner图一直显示调取1.jpg。

设置步骤

第一步:打开网站管理后台;

第二步:点击控制台、外观;

第三步:点击“编辑当前外观”,点击右侧“post.php”代码文件,即编辑文章页模板文件;

第四步:找到如下代码文件

<!-- 不是加密文章 -->
<div class="pattern-center">
<div class="pattern-attachment-img" style="background-image: url(
<?php 
    if (array_key_exists('img',unserialize($this->___fields()))){
        $this->fields->img(); 
    } else {
        if(img_postthumb($this->content)){
            echo img_postthumb($this->content);
        }else {
            echo theurl.'images/postbg/'.mt_rand(1,3).'.jpg';
        } 
    }
?>
)"></div>

第五步:将上述代码修改为

<!-- 不是加密文章 -->
<div class="pattern-center">
<div class="pattern-attachment-img" style="background-image: url(
  <?php 
      if($theurl==$this->options->themeUrl){
           $this->options->headimg();
      }else{
           echo theurl.'images/postbg/'.mt_rand(1,3).'.jpg';}
?>
)"></div>

第六步:将上述代码里

echo theurl.'images/postbg/'.mt_rand(1,3).'.jpg';

改为

echo theurl.'images/postbg/'.mt_rand(1,1).'.jpg';

通过上述步骤即可将文章页banner图设置为固定调取路径文件夹里的1.jpg固定文件。

请输入图片描述

欢迎扫码添加老刘微信交流Akina For Typecho主题

嗨,叫我老刘就好。我已从事知识产权行业13年,这个博客主要围绕商标版权做经验分享。希望能帮到大家。有商标、版权业务方面的需求可以直接扫码添加我的微信咨询。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注