Skip to content

Commit

Permalink
Optimize lazy loading of article images
Browse files Browse the repository at this point in the history
  • Loading branch information
liaocp666 committed Jun 29, 2023
1 parent c0d2e24 commit 7b6b351
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion component/post-item-moment.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
</div>
</div>
<div class="markdown-body !bg-stone-100 rounded p-5 relative dark:!bg-[#0d1117] !text-neutral-900 dark:!text-neutral-200" id="moment">
<?php $this->content(); ?>
<?php echo handleContent($this->content);?>
</div>
</div>
4 changes: 2 additions & 2 deletions core/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function getAvatarByMail($mail, $isOwner = false)
$md5MailLower = md5($mailLower);
$qqMail = str_replace("@qq.com", "", $mailLower);
if (strstr($mailLower, "qq.com") && is_numeric($qqMail) && strlen($qqMail) < 11 && strlen($qqMail) > 4) {
return getQQAvatar($qqMail);
return $gravatarsUrl . $md5MailLower . "?d=mm";
} else {
return $gravatarsUrl . $md5MailLower . "?d=mm";
}
Expand Down Expand Up @@ -198,7 +198,7 @@ function imageLazyLoad($content)
{
$pattern = '/<img(.*?)src(.*?)=(.*?)"(.*?)">/i';
$replacement =
'<img$1data-original$3="$4"$5 class="lazyload" src="data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=">';
'<img$1src$3="$4"$5 loading="lazy">';
return preg_replace($pattern, $replacement, $content);
}

Expand Down
2 changes: 1 addition & 1 deletion page-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div></div>
<?php $this->need("component/post-title.php"); ?>
<div class="markdown-body dark:!bg-[#161829] dark:!bg-[#0d1117] !text-neutral-900 dark:!text-gray-400" itemprop="articleBody">
<?php $this->content(); ?>
<?php echo handleContent($this->content); ?>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<?php if (isPluginAvailable("Links")) {
Expand Down
2 changes: 1 addition & 1 deletion page.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div></div>
<?php $this->need("component/post-title.php"); ?>
<div class="markdown-body dark:!bg-[#161829] dark:!bg-[#0d1117] !text-neutral-900 dark:!text-gray-400" itemprop="articleBody">
<?php $this->content(); ?>
<?php echo handleContent($this->content);?>
</div>
<div class="flex flex-row gap-x-2 " id="post-tag">
<?php $this->tags(" ", true, ""); ?>
Expand Down
2 changes: 1 addition & 1 deletion post.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div></div>
<?php $this->need("component/post-title.php"); ?>
<div class="markdown-body dark:!bg-[#161829] dark:!bg-[#0d1117] !text-neutral-900 dark:!text-gray-400" itemprop="articleBody">
<?php $this->content(); ?>
<?php echo handleContent($this->content);?>
</div>
<div class="flex flex-row gap-x-2 " id="post-tag">
<?php $this->tags(" ", true, ""); ?>
Expand Down

0 comments on commit 7b6b351

Please sign in to comment.