feat(frontend): replace lazy loading with zibll lazysizes

This commit is contained in:
2026-08-18 01:33:38 +08:00
parent 02571eecd6
commit 435ee1daa7
78 changed files with 1515 additions and 909 deletions
+9 -9
View File
@@ -88,12 +88,9 @@ if (!function_exists('aksrt_render_comment_smilie')) :
if (!isset($map[$lookup])) {
return '[g=' . esc_html($raw) . ']';
}
return sprintf(
'<img class="smilie-icon" src="%1$s" alt="%2$s" title="%2$s" width="30" height="30" loading="lazy" decoding="async" data-smilie="%3$s" />',
esc_url($map[$lookup]),
esc_attr('[' . $lookup . ']'),
esc_attr($lookup)
);
$label = esc_attr('[' . $lookup . ']');
return '<img' . aksrt_get_lazy_attr('lazy_comment', (string) $map[$lookup], 'smilie-icon', aksrt_get_lazy_thumb('sm'))
. ' alt="' . $label . '" title="' . $label . '" width="30" height="30" decoding="async" data-smilie="' . esc_attr($lookup) . '">';
}
endif;
@@ -103,9 +100,12 @@ if (!function_exists('aksrt_render_comment_content')) :
*/
function aksrt_render_comment_content(string $content): string {
// [img=url]
$rendered = preg_replace(
$rendered = preg_replace_callback(
'/\[img=(https?:\/\/[^\s\[\]]+)\]/i',
'<img class="box-img comment-inline-img" src="$1" alt="' . esc_attr__('评论图片', 'aksrt') . '" loading="lazy" decoding="async" />',
static function (array $matches): string {
return '<img' . aksrt_get_lazy_attr('lazy_comment', (string) $matches[1], 'box-img comment-inline-img', aksrt_get_lazy_thumb('lg'))
. ' alt="' . esc_attr__('评论图片', 'aksrt') . '" decoding="async">';
},
$content
);
// [code]...[/code]
@@ -134,7 +134,7 @@ if (!function_exists('aksrt_render_comment_content')) :
'title' => true,
'width' => true,
'height' => true,
'loading' => true,
'data-src' => true,
'decoding' => true,
'data-smilie' => true,
'data-src' => true,