From d71315f3202497c441f375dbde91749b4d721e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 25 Jan 2026 23:48:23 +0100 Subject: [PATCH] fix: `listing:image-lazy-loading` does not work for values of `true` or `false` Fixes #13951 --- .../website/listing/website-listing-read.ts | 26 ++++++++++++++----- .../listing/website-listing-template.ts | 2 ++ .../website/listing/item-default.ejs.md | 2 +- .../projects/website/listing/item-grid.ejs.md | 2 +- .../website/listing/listing-table.ejs.md | 2 +- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/project/types/website/listing/website-listing-read.ts b/src/project/types/website/listing/website-listing-read.ts index c8aacd50096..05b8ff153c4 100644 --- a/src/project/types/website/listing/website-listing-read.ts +++ b/src/project/types/website/listing/website-listing-read.ts @@ -393,14 +393,16 @@ export function completeListingItems( debug(`[listing] Processing image match`); const progressive = imgMatch[1] === "true"; const imgHeight = imgMatch[2]; - const listingId = imgMatch[3]; - const docRelativePath = imgMatch[4]; + const lazy = imgMatch[3] !== "false"; + const listingId = imgMatch[4]; + const docRelativePath = imgMatch[5]; const docAbsPath = join(projectOutputDir(context), docRelativePath); const imgPlaceholder = imagePlaceholder( listingId, docRelativePath, progressive, imgHeight, + lazy, ); debug(`[listing] ${docAbsPath}`); debug(`[listing] ${imgPlaceholder}`); @@ -435,6 +437,7 @@ export function completeListingItems( }, progressive, imgHeight, + lazy, ); debug(`[listing] replacing: ${docAbsPath}`); @@ -454,7 +457,7 @@ export function completeListingItems( }; fileContents = fileContents.replace( imgPlaceholder, - imageSrc(imagePreview, progressive, imgHeight), + imageSrc(imagePreview, progressive, imgHeight, lazy), ); } else { debug(`[listing] using empty div: ${docAbsPath}`); @@ -501,11 +504,14 @@ export function imagePlaceholder( file: string, progressive: boolean, height?: string, + lazy?: boolean, ): string { return file ? `` + }, height=${height ? height : ""}, lazy=${ + lazy === false ? "false" : "true" + }]:${id}:${file} -->` : ""; } @@ -517,7 +523,7 @@ const descriptionPlaceholderRegex = //; const imagePlaceholderRegex = - //; + //; function hydrateListing( format: Format, @@ -1202,8 +1208,14 @@ async function listItemFromFile( } } -function imageSrc(image: PreviewImage, progressive: boolean, height?: string) { - return `
{
const pageSize = listing[kPageSize];
return imagePlaceholder(
@@ -454,6 +455,7 @@ export function reshapeListing(
itemPath,
itemNumber > pageSize,
listing[kImageHeight] as string,
+ lazy,
);
};
diff --git a/src/resources/projects/website/listing/item-default.ejs.md b/src/resources/projects/website/listing/item-default.ejs.md
index 91114a7867f..823f32c18d3 100644
--- a/src/resources/projects/website/listing/item-default.ejs.md
+++ b/src/resources/projects/website/listing/item-default.ejs.md
@@ -45,7 +45,7 @@ print(`