feat(frontend): replace lazy loading with zibll lazysizes
This commit is contained in:
@@ -67,14 +67,24 @@ final class GeneralRenderer {
|
||||
return RendererHelpers::empty_state(__('请配置视频地址', 'aksrt'));
|
||||
}
|
||||
$ratio = (string) $i['ratio'];
|
||||
return '<div class="aksrt-widget-video aksrt-widget-video--' . esc_attr(str_replace(':', '-', $ratio)) . '" data-video-url="' . $url . '" data-video-poster="' . esc_url((string) $i['poster']) . '" data-autoplay="' . (!empty($i['autoplay']) ? '1' : '0') . '" data-muted="' . (!empty($i['muted']) ? '1' : '0') . '"><video controls playsinline preload="metadata"' . (!empty($i['autoplay']) ? ' autoplay' : '') . (!empty($i['muted']) ? ' muted' : '') . (!empty($i['poster']) ? ' poster="' . esc_url((string) $i['poster']) . '"' : '') . '><source src="' . $url . '"></video><p class="aksrt-widget-media-error" role="alert" aria-live="assertive" hidden>' . esc_html__('视频加载失败,请稍后重试。', 'aksrt') . '</p></div>';
|
||||
if (aksrt_is_lazy('lazy_other')) {
|
||||
$video_attr = ' class="lazyload" src="" data-src="' . $url . '"';
|
||||
$poster_attr = !empty($i['poster']) ? ' data-poster="' . esc_url((string) $i['poster']) . '"' : '';
|
||||
} else {
|
||||
$video_attr = ' src="' . $url . '"';
|
||||
$poster_attr = !empty($i['poster']) ? ' poster="' . esc_url((string) $i['poster']) . '"' : '';
|
||||
}
|
||||
return '<div class="aksrt-widget-video aksrt-widget-video--' . esc_attr(str_replace(':', '-', $ratio)) . '" data-video-url="' . $url . '" data-video-poster="' . esc_url((string) $i['poster']) . '" data-autoplay="' . (!empty($i['autoplay']) ? '1' : '0') . '" data-muted="' . (!empty($i['muted']) ? '1' : '0') . '"><video controls playsinline preload="metadata"' . $video_attr . $poster_attr . (!empty($i['autoplay']) ? ' autoplay' : '') . (!empty($i['muted']) ? ' muted' : '') . '></video><p class="aksrt-widget-media-error" role="alert" aria-live="assertive" hidden>' . esc_html__('视频加载失败,请稍后重试。', 'aksrt') . '</p></div>';
|
||||
}
|
||||
|
||||
private static function render_embed(array $i): string {
|
||||
if (empty($i['url'])) {
|
||||
return RendererHelpers::empty_state(__('请配置嵌入地址', 'aksrt'));
|
||||
}
|
||||
return '<div class="aksrt-widget-embed" style="--aksrt-embed-ratio:' . esc_attr((string) (float) $i['ratio']) . '%"><iframe src="' . esc_url((string) $i['url']) . '" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"' . (!empty($i['allow_fullscreen']) ? ' allowfullscreen' : '') . ' title="' . esc_attr__('嵌入内容', 'aksrt') . '"></iframe></div>';
|
||||
$src_attr = aksrt_is_lazy('lazy_other')
|
||||
? ' class="lazyload" src="" data-src="' . esc_url((string) $i['url']) . '"'
|
||||
: ' src="' . esc_url((string) $i['url']) . '"';
|
||||
return '<div class="aksrt-widget-embed" style="--aksrt-embed-ratio:' . esc_attr((string) (float) $i['ratio']) . '%"><iframe' . $src_attr . ' referrerpolicy="strict-origin-when-cross-origin"' . (!empty($i['allow_fullscreen']) ? ' allowfullscreen' : '') . ' title="' . esc_attr__('嵌入内容', 'aksrt') . '"></iframe></div>';
|
||||
}
|
||||
|
||||
private static function render_media_cards(array $i): string {
|
||||
|
||||
Reference in New Issue
Block a user