8.9 修改代码高亮样式
This commit is contained in:
1 parent
62cac6c7b0
commit
2e11da0d0b
15 files changed
+2414
-2410
No files matched your search
@@ -91,20 +91,20 @@
|
||||
<p>
|
||||
<img data-lazy-src="/pics/2021/10/814315235.png" alt="" class="lazyload"></p>
|
||||
<p>图片显示的代码是我修改之后的,你只需要将</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg)/i",path);
|
||||
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg)/i",path);
|
||||
</span></span></code></pre></div><p>改为</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg|webp)/i",path);
|
||||
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg|webp)/i",path);
|
||||
</span></span></code></pre></div><p>然后找到</p>
|
||||
<p>typecho的var/Widget/Abstract/Contents.php</p>
|
||||
<p>差不多是686行</p>
|
||||
<p>
|
||||
<img data-lazy-src="/pics/2021/10/402523352.png" alt="" class="lazyload"></p>
|
||||
<p>然后将</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>$value['attachment']->isImage = in_array($content['type'], array('jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp'));
|
||||
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>$value['attachment']->isImage = in_array($content['type'], array('jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp'));
|
||||
</span></span></code></pre></div><p>改为</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>$value['attachment']->isImage = in_array($content['type'], array('jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp', 'webp'));
|
||||
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>$value['attachment']->isImage = in_array($content['type'], array('jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp', 'webp'));
|
||||
</span></span></code></pre></div><p>然后找到var/Typecho/Common.php,差不多是1399行,我们这里多加一行代码</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>'webp' => 'image/webp',
|
||||
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>'webp' => 'image/webp',
|
||||
</span></span></code></pre></div><p>然后去typecho的后台,找到设置-基本,这个地方在其他文件加入webp,然后博客就可以完美支持webp格式图片了</p>
|
||||
<p>
|
||||
<img data-lazy-src="/pics/2021/10/46607755.png" alt="" class="lazyload"></p>
|
||||
@@ -154,7 +154,7 @@ https://squoosh.app</a></p>
|
||||
<h2 id="让wordpress支持webp格式图片">让WordPress支持webp格式图片</h2>
|
||||
<p>因为我之前使用的博客系统是WordPress,当然也有让WordPress支持webp格式图片的方法</p>
|
||||
<p>直接在自己的主题文件的function.php里面加入下面代码即可完美支持webp格式图片</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>//下方一段为webp格式图片支持代码 function bzg_filter_mime_types( $array ) { $array['webp'] = 'image/webp'; return $array; } add_filter( 'mime_types', 'bzg_filter_mime_types', 10, 1 );
|
||||
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>//下方一段为webp格式图片支持代码 function bzg_filter_mime_types( $array ) { $array['webp'] = 'image/webp'; return $array; } add_filter( 'mime_types', 'bzg_filter_mime_types', 10, 1 );
|
||||
</span></span><span style="display:flex;"><span>//下方为webp格式图片在媒体库预览图像支持代码 function bzg_file_is_displayable_image($result, $path) { $info = @getimagesize( $path ); if($info['mime'] == 'image/webp') { $result = true; } return $result; } add_filter( 'file_is_displayable_image', 'bzg_file_is_displayable_image', 10, 2 );
|
||||
</span></span></code></pre></div><p>基本上就分享这么多,晚安,我的朋友们</p>
|
||||
|
||||
|
||||
Reference in new issue
Block a user