惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

记录生活,精彩一刻 - webp

暂无文章

Typecho 1.2.0 如何支持webp格式图片
Huo · 2022-09-04 · via 记录生活,精彩一刻 - webp

Typecho 1.2.0 依然默认不支持.webp格式图片,实属拉胯。google 了一下,发现目前全网似乎还没有 Typecho 1.2.0 网站支持webp格式图片的教程。索性自己照着网上现有的 Typecho 1.0 网站支持webp格式图片教程,“摸着石头过河”,探索了一下 Typecho 1.2.0 支持 webp格式图片的教程。

Webp图片格式

具体步骤

  1. 找到 Typecho 网站所在文件夹下的以下文件:
var/Widget/Themes/Rows.php

差不多是第48行的位置;

将以下代码

return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg)/i",path);

修改为:

return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg|webp)/i",path);
  1. 保存修改后,找到 Typecho 网站所在文件夹下的以下文件:
var/Widget/Base/Contents.php

定位到第557行,将以下代码:

$value['attachment']->isImage = in_array($content['type'], ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp']);

修改为:

$value['attachment']->isImage = in_array($content['type'], ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp', 'webp']);
  1. 最后再找到 Typecho 网站所在文件夹下的以下文件:
var/Typecho/Common.php

找到图片格式所在的行,大约是在1259行后的位置添加下面这一行代码:

'webp' => 'image/webp',

最后进入 Typecho 网站后台,前往 设置 > 基本,在允许上传的文件类型部分,勾选其他格式,并添加webp,然后点击保存设置。

按照以上步骤完成修改后,后续新发布的文章将支持webp格式图片。