微博图床使用中等尺寸图片作为首页图和文章图提高网站加载速度

如果图片链接使用的是中等尺寸图片 mv690,则需要将打开后的图片链接参数改为原图 large,达到显示原图的目的。(ps:打开图片可能会出现 坏图(被微博吞了)的情况)

主题 post.php文件修改第56行

<?php echo $img['url']; ?>

改为

<?php echo str_replace('mw690', 'large', $img['url']); ?>

如果图片链接使用的是原图 large,则需要将首页封面图片和文章页图片链接参数改为 mv690,使首页封面图片和文章页图片显示为中等图片提高网站加载速度。(ps:首页封面图片和文章页图片可能会出现 坏图(被微博吞了)的情况)

主题 post.php文件修改第57行

<?php echo $img['url'].($this->options->detailImgParm ? $this->options->detailImgParm : ''); ?>

改为

<?php echo $this->options->detailImgParm ? str_replace('large', $this->options->detailImgParm, $img['url']) : $img['url']; ?>

主题 index.list.php文件修改第5行

$this->fields->thumb.($this->options->thumbImgParm ? $this->options->thumbImgParm : '') : getPostImg($this, $this->options->wholeSrc)[0]['url'].($this->options->thumbImgParm ? $this->options->thumbImgParm : ''); endif; ?>"

改为

($this->options->thumbImgParm ? str_replace('large', $this->options->thumbImgParm, $this->fields->thumb) : $this->fields->thumb) : ($this->options->thumbImgParm ? str_replace('large', $this->options->thumbImgParm, getPostImg($this, $this->options->wholeSrc)[0]['url']) : getPostImg($this, $this->options->wholeSrc)[0]['url']); endif; ?>"
最后修改:2023 年 09 月 27 日
如果觉得我的文章对你有用,请随意赞赏