Skip to content

Commit

Permalink
后台文章编辑器预览文章图片追加loading="lazy"
Browse files Browse the repository at this point in the history
后台文章编辑器预览文章图片追加loading="lazy"支持浏览器原生懒加载加载
typecho#1727
  • Loading branch information
jrotty committed Feb 19, 2024
1 parent 0a40b1e commit 0260c31
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions admin/editor-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
html = '<div class="summary">' + summary + '</div>'
+ '<div class="details">' + details + '</div>';
}

// 给img追加loading="lazy"
html = html.replace(/<img([^>]+)>/gi, '<img loading="lazy"$1>');

// 替换block
html = html.replace(/<(iframe|embed)\s+([^>]*)>/ig, function (all, tag, src) {
Expand Down

0 comments on commit 0260c31

Please sign in to comment.