fix(frontend): remove residual post thumbnail lazy path
This commit is contained in:
@@ -7,7 +7,6 @@ export const thumbSchema = {
|
||||
thumb_priority: 'featured,attachment,resource,custom',
|
||||
thumb_fallback: 'placeholder',
|
||||
thumb_spare_images: [],
|
||||
thumb_lazy: true,
|
||||
thumb_aspect_ratio: '16:9',
|
||||
list_thumb_fit: 'cover',
|
||||
thumb_multi_enabled: false,
|
||||
@@ -63,7 +62,6 @@ export const thumbSchema = {
|
||||
{ key: 'thumb_multi_enabled', label: '多图卡片', type: 'switch', default: false, help: '当文章有多张图片时,在列表中展示多图预览' },
|
||||
{ key: 'thumb_multi_count', label: '最多显示几张', type: 'number', default: 3, min: 2, max: 6, dependsOn: { key: 'thumb_multi_enabled', value: true } },
|
||||
{ key: 'mult_thumb_cat', label: '按分类多图显示', type: 'taxonomy_select', taxonomy: 'category', multiple: true, default: [], help: '选择的分类下所有文章自动显示多张缩略图' },
|
||||
{ key: 'thumb_lazy', label: '懒加载', type: 'switch', default: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -39,7 +39,6 @@ if (!function_exists('aksrt_renderer_defaults')) {
|
||||
'show_thumb' => true,
|
||||
'thumb_ratio' => '4:3',
|
||||
'thumb_fit' => 'cover',
|
||||
'thumb_lazy' => true,
|
||||
'thumb_if_has' => false,
|
||||
'target_blank' => false,
|
||||
'title_html' => '',
|
||||
@@ -328,9 +327,13 @@ if (!function_exists('aksrt_renderer_resolve_images')) {
|
||||
}
|
||||
|
||||
$thumb_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_thumb_settings() : [];
|
||||
$allow_fallback = !empty($thumb_settings['rand_thumb']) || !empty($cfg['thumb_if_has']);
|
||||
if ($primary === '' && $allow_fallback) {
|
||||
$primary = aksrt_renderer_random_fallback_image($post_id);
|
||||
$fallback = sanitize_key((string) ($thumb_settings['fallback'] ?? 'placeholder'));
|
||||
if ($primary === '' && empty($cfg['thumb_if_has'])) {
|
||||
if ($fallback === 'random') {
|
||||
$primary = aksrt_renderer_random_fallback_image($post_id);
|
||||
} elseif ($fallback === 'placeholder') {
|
||||
$primary = aksrt_get_lazy_thumb();
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -170,9 +170,7 @@ if (!function_exists('aksrt_renderer_mini')) {
|
||||
$target_attr = !empty($cfg['target_blank']) ? ' target="_blank"' : '';
|
||||
if ($cfg['show_thumb'] && !empty($data['has_img'])) {
|
||||
$fit_class = !empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover';
|
||||
$thumb_attr = !empty($cfg['thumb_lazy'])
|
||||
? aksrt_get_lazy_attr('lazy_posts_thumb', (string) $data['img_url'], $fit_class)
|
||||
: ' class="' . esc_attr($fit_class) . '" src="' . esc_url($data['img_url']) . '"';
|
||||
$thumb_attr = aksrt_get_lazy_attr('lazy_posts_thumb', (string) $data['img_url'], $fit_class);
|
||||
$thumb_img = '<img' . $thumb_attr . ' alt="' . esc_attr($data['title']) . '">';
|
||||
|
||||
$thumb_html = '<a href="' . esc_url($data['permalink']) . '" class="item-thumbnail" aria-label="' . esc_attr($data['title']) . '"' . $target_attr . '>' . $thumb_img . '</a>';
|
||||
|
||||
@@ -113,9 +113,7 @@ if (!function_exists('aksrt_renderer_thumb')) {
|
||||
$has_real_img = !empty($data['has_real_img']);
|
||||
|
||||
$fit_class = !empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover';
|
||||
$img_attr = !empty($cfg['thumb_lazy'])
|
||||
? aksrt_get_lazy_attr('lazy_posts_thumb', $img, $fit_class)
|
||||
: ' class="' . esc_attr($fit_class) . '" src="' . esc_url($img) . '"';
|
||||
$img_attr = aksrt_get_lazy_attr('lazy_posts_thumb', $img, $fit_class);
|
||||
$img_html = '<img' . $img_attr . ' alt="' . esc_attr($title) . '">';
|
||||
|
||||
$sticky_html = ($is_sticky && !empty($cfg['badge_show']))
|
||||
|
||||
@@ -55,7 +55,6 @@ class SchemaPostList {
|
||||
['key' => 'thumb_multi_enabled', 'label' => '多图卡片', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'thumb_multi_count', 'label' => '最多显示几张', 'type' => 'number', 'default' => 3, 'min' => 2, 'max' => 6, 'dependsOn' => ['key' => 'thumb_multi_enabled', 'value' => true]],
|
||||
['key' => 'mult_thumb_cat', 'label' => '按分类多图显示', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'dependsOn' => ['key' => 'thumb_multi_enabled', 'value' => true]],
|
||||
['key' => 'thumb_lazy', 'label' => '懒加载', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'thumb_multi_enabled', 'value' => true]],
|
||||
]],
|
||||
],
|
||||
],
|
||||
|
||||
@@ -209,7 +209,6 @@ trait DisplayPageGroups {
|
||||
'thumb_priority' => implode(',', $thumb['priority']),
|
||||
'thumb_fallback' => $thumb['fallback'],
|
||||
'thumb_spare_images' => $thumb['spare_images'],
|
||||
'thumb_lazy' => $thumb['lazy'],
|
||||
'thumb_aspect_ratio' => $thumb['aspect_ratio'],
|
||||
'thumb_multi_enabled' => $thumb['multi_enabled'],
|
||||
'thumb_multi_count' => $thumb['multi_count'],
|
||||
|
||||
@@ -174,7 +174,6 @@ class PostDisplay {
|
||||
'aspect_ratio' => $aspect_ratio,
|
||||
'multi_enabled' => !empty($settings['thumb_multi_enabled']),
|
||||
'multi_count' => max(2, min(6, (int) ($settings['thumb_multi_count'] ?? 3))),
|
||||
'lazy' => !isset($settings['thumb_lazy']) || !empty($settings['thumb_lazy']),
|
||||
'fit' => in_array(sanitize_key((string) ($settings['list_thumb_fit'] ?? 'cover')), ['cover', 'contain'], true) ? sanitize_key((string) ($settings['list_thumb_fit'] ?? 'cover')) : 'cover',
|
||||
'slides_s' => !isset($settings['list_thumb_slides_s']) || !empty($settings['list_thumb_slides_s']),
|
||||
'video_s' => !isset($settings['list_thumb_video_s']) || !empty($settings['list_thumb_video_s']),
|
||||
|
||||
@@ -119,6 +119,23 @@ test('one lazySizes runtime owns dynamic media, backgrounds, videos, and IAS', (
|
||||
assert.doesNotMatch(widgets, /IntersectionObserver/);
|
||||
});
|
||||
|
||||
test('post lists have no second lazy switch and keep Zibll fallback thumbnails', () => {
|
||||
const config = read('inc/helpers/posts-renderer/config.php');
|
||||
const postData = read('inc/helpers/posts-renderer/post-data.php');
|
||||
const markup = read('inc/helpers/posts-renderer/markup.php');
|
||||
const phpSchema = read('src/Admin/Schema/SchemaPostList.php');
|
||||
const vueSchema = read('assets/admin/src/schema/sections/post-list/thumb.js');
|
||||
const legacyKey = 'thumb_' + 'lazy';
|
||||
|
||||
for (const source of [config, postData, markup, phpSchema, vueSchema]) {
|
||||
assert.equal(source.includes(legacyKey), false);
|
||||
}
|
||||
assert.match(postData, /aksrt_get_lazy_attr\('lazy_posts_thumb', \$img, \$fit_class\)/);
|
||||
assert.match(markup, /aksrt_get_lazy_attr\('lazy_posts_thumb', \(string\) \$data\['img_url'\], \$fit_class\)/);
|
||||
assert.match(config, /\$fallback\s*=\s*sanitize_key[\s\S]*?\$fallback\s*===\s*'placeholder'[\s\S]*?aksrt_get_lazy_thumb\(\)/);
|
||||
assert.doesNotMatch(config, /rand_thumb/);
|
||||
});
|
||||
|
||||
test('legacy lazy identifiers and theme-native loading attributes are gone', () => {
|
||||
const files = sourceFiles(root).filter((file) => !file.endsWith('lazyload-contract.test.cjs'));
|
||||
const source = files.map((file) => fs.readFileSync(file, 'utf8')).join('\n');
|
||||
@@ -128,6 +145,7 @@ test('legacy lazy identifiers and theme-native loading attributes are gone', ()
|
||||
'get_' + 'lazyload_config',
|
||||
'aksrt_' + 'lazy_img_attrs',
|
||||
'aksrt_' + 'lazy_loading',
|
||||
'thumb_' + 'lazy',
|
||||
];
|
||||
for (const token of forbidden) assert.equal(source.includes(token), false, token);
|
||||
assert.doesNotMatch(source, /aksrt-lazy(?!sizes)/);
|
||||
|
||||
Reference in New Issue
Block a user