feat(frontend): replace lazy loading with zibll lazysizes
This commit is contained in:
1 parent
02571eecd6
commit
435ee1daa7
78 files changed
+1515
-909
No files matched your search
@@ -24,7 +24,7 @@ if (!function_exists('aksrt_graphic_card')) :
|
||||
* @type string $text2 Secondary text.
|
||||
* @type string $text3 Tertiary / badge text (HTML allowed for icon+count).
|
||||
* @type string $more Extra absolute HTML (badge etc).
|
||||
* @type bool $lazy Use aksrt-lazy data-src.
|
||||
* @type bool $lazy Use the Zibll lazySizes contract.
|
||||
* @type int|float $height_scale Padding-bottom % (0 = default CSS).
|
||||
* @type int|float $mask_opacity 0–100 overlay opacity.
|
||||
* @type string $hide pc|m|'' hide on device.
|
||||
@@ -89,21 +89,21 @@ if (!function_exists('aksrt_graphic_card')) :
|
||||
$link_target = sanitize_text_field((string) ($link['target'] ?? ''));
|
||||
|
||||
$lazy = !empty($args['lazy']);
|
||||
$placeholder = get_template_directory_uri() . '/assets/img/placeholder.svg';
|
||||
$media = '';
|
||||
if ($video_url !== '' && !(function_exists('wp_is_mobile') && wp_is_mobile())) {
|
||||
$poster = $img_url !== '' ? ' poster="' . esc_url($img_url) . '"' : '';
|
||||
if ($lazy) {
|
||||
$media = '<video autoplay loop muted playsinline class="fit-cover aksrt-lazy lazyload" data-src="' . esc_url($video_url) . '" src=""' . $poster . '></video>';
|
||||
if ($lazy && aksrt_is_lazy('lazy_other')) {
|
||||
$poster = $img_url !== '' ? ' data-poster="' . esc_url($img_url) . '"' : '';
|
||||
$media = '<video autoplay loop muted playsinline class="fit-cover lazyload" data-src="' . esc_url($video_url) . '" src=""' . $poster . '></video>';
|
||||
} else {
|
||||
$poster = $img_url !== '' ? ' poster="' . esc_url($img_url) . '"' : '';
|
||||
$media = '<video autoplay loop muted playsinline class="fit-cover" src="' . esc_url($video_url) . '"' . $poster . '></video>';
|
||||
}
|
||||
} elseif ($img_url !== '') {
|
||||
$alt = (string) ($args['alt'] !== '' ? $args['alt'] : __('图片', 'aksrt'));
|
||||
if ($lazy) {
|
||||
$media = '<img class="fit-cover aksrt-lazy lazyload" data-src="' . esc_url($img_url) . '" src="' . esc_url($placeholder) . '" alt="' . esc_attr($alt) . '" loading="lazy" />';
|
||||
$media = '<img' . aksrt_get_lazy_attr('lazy_other', $img_url, 'fit-cover') . ' alt="' . esc_attr($alt) . '">';
|
||||
} else {
|
||||
$media = '<img class="fit-cover" src="' . esc_url($img_url) . '" alt="' . esc_attr($alt) . '" loading="lazy" />';
|
||||
$media = '<img class="fit-cover" src="' . esc_url($img_url) . '" alt="' . esc_attr($alt) . '">';
|
||||
}
|
||||
}
|
||||
if ($media === '') {
|
||||
@@ -228,7 +228,7 @@ if (!function_exists('aksrt_author_minicard')) :
|
||||
? aksrt_get_user_home_url($user_id)
|
||||
: get_author_posts_url($user_id);
|
||||
|
||||
$avatar_box = '<div class="avatar-img"><a href="' . esc_url($home) . '"><img class="avatar" src="' . esc_url($avatar_url) . '" alt="" loading="lazy" width="42" height="42" /></a></div>';
|
||||
$avatar_box = '<div class="avatar-img"><a href="' . esc_url($home) . '"><img' . aksrt_get_lazy_attr('lazy_avatar', $avatar_url, 'avatar', aksrt_get_lazy_thumb('sm')) . ' alt="" width="42" height="42"></a></div>';
|
||||
|
||||
$name = function_exists('aksrt_get_user_name')
|
||||
? aksrt_get_user_name([
|
||||
@@ -260,7 +260,7 @@ if (!function_exists('aksrt_author_minicard')) :
|
||||
|
||||
$blur = '';
|
||||
if ($blur_bg) {
|
||||
$blur = '<div class="abs-blur-bg blur"><img src="' . esc_url($avatar_url) . '" alt="" loading="lazy" /></div>';
|
||||
$blur = '<div class="abs-blur-bg blur"><img' . aksrt_get_lazy_attr('lazy_avatar', $avatar_url, '', aksrt_get_lazy_thumb('sm')) . ' alt=""></div>';
|
||||
}
|
||||
|
||||
return '<div class="author-minicard radius8 relative-h ' . esc_attr($class) . '">'
|
||||
|
||||
Reference in new issue
Block a user