当发表的文章中有很多图片的时候,图片的大小参差不齐又或者很长,很影响阅读体验。我们可以通过限制最大图片的宽高来达到更好的阅读效果。

同时因为有灯箱的存在也不会影响到图片本身会看不清的问题。

食用方法

  1. 首先找到根目录下的/var/HyperDown.php文件
  2. 然后搜索img找到如下代码
"<img src=\"{$url}\" alt=\"{$escaped}\" title=\"{$escaped}\" >"
"<img src=\"{$self->_definitions[$matches[2]]}\" alt=\"{$escaped}\" title=\"{$escaped}\">"
  1. 替换为
"<img src=\"{$url}\" alt=\"{$escaped}\" title=\"{$escaped}\" style=\"max-width:460px;max-height:600px; \">"
"<img src=\"{$self->_definitions[$matches[2]]}\" alt=\"{$escaped}\" title=\"{$escaped}\" style=\"max-width:460px;max-height:600px; \">"

其实就是添加了一个style=max-width:xx;max-height:xx的属性而已

设置的是限制图片最大高度为600px,最大宽度为460px。

大小可以根据自己的习惯进行调整 保存后刷新即可看到实际效果了。

Last modification:October 29, 2020
如果觉得我的文章对你有用,请随意赞赏