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

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

记录生活,精彩一刻 - 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格式图片。