From cb4f5a722c3884a5dc07b3735ba7d7a8b322216a Mon Sep 17 00:00:00 2001 From: setop <7794056+setop@users.noreply.github.com> Date: Thu, 7 May 2026 02:34:14 +0200 Subject: [PATCH 1/2] card: add top image attributes for lazy loading This will be useful for long image gallery. Developped according to [HTML specs of img tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#lazy) --- .../sqlpage/migrations/31_card_docs_update.sql | 6 +++--- .../sqlpage/migrations/75_card_top_image_attributes.sql | 7 +++++++ sqlpage/templates/card.handlebars | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 examples/official-site/sqlpage/migrations/75_card_top_image_attributes.sql diff --git a/examples/official-site/sqlpage/migrations/31_card_docs_update.sql b/examples/official-site/sqlpage/migrations/31_card_docs_update.sql index d3a5f00c4..b010034d7 100644 --- a/examples/official-site/sqlpage/migrations/31_card_docs_update.sql +++ b/examples/official-site/sqlpage/migrations/31_card_docs_update.sql @@ -58,9 +58,9 @@ INSERT INTO example(component, description, properties) VALUES ('card', 'A gallery of images.', json('[ {"component":"card", "title":"My favorite animals in pictures", "columns": 3}, - {"title": "Lynx", "description_md": "The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Lynx_lynx-4.JPG/640px-Lynx_lynx-4.JPG", "icon":"star" }, - {"title": "Squirrel", "description_md": "The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Tamias-rufus-001.jpg/640px-Tamias-rufus-001.jpg" }, - {"title": "Spider", "description_md": "The **jumping spider family** (_Salticidae_) contains more than 600 described genera and about *6000 described species*, making it the largest family of spiders with about 13% of all species.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Jumping_spiders_%28Salticidae%29.jpg/640px-Jumping_spiders_%28Salticidae%29.jpg" } + {"title": "Lynx", "description_md": "The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Lynx_lynx_-_05.jpg/330px-Lynx_lynx_-_05.jpg", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true, "icon":"star" }, + {"title": "Squirrel", "description_md": "The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/American_squirrel_eating_nut%2C_13_Jun_2013.JPG/330px-American_squirrel_eating_nut%2C_13_Jun_2013.JPG", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true }, + {"title": "Spider", "description_md": "The **jumping spider family** (_Salticidae_) contains more than 600 described genera and about *6000 described species*, making it the largest family of spiders with about 13% of all species.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Australian_orb_weaver_spinning_web.jpg/330px-Australian_orb_weaver_spinning_web.jpg", "top_image_width": 330, "top_image_height": 495, "top_image_lazy": true } ]')), ('card', 'Beautifully colored cards with variable width. The blue card (width 6) takes half the screen, whereas of the red and green cards have the default width of 3', json('[ diff --git a/examples/official-site/sqlpage/migrations/75_card_top_image_attributes.sql b/examples/official-site/sqlpage/migrations/75_card_top_image_attributes.sql new file mode 100644 index 000000000..35ed3113a --- /dev/null +++ b/examples/official-site/sqlpage/migrations/75_card_top_image_attributes.sql @@ -0,0 +1,7 @@ +INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'card', * FROM (VALUES + -- item level + ('top_image_lasy', 'Whether the top image must be lazily or eagerly loaded. Defaults to false, meaning eagerly', 'BOOLEAN', FALSE, TRUE), + ('top_image_width', 'Specify the top image width, in pixel. Help preventing a layout shift', 'INTEGER', FALSE, TRUE), + ('top_image_height', 'Specify the top image height, in pixel. Help preventing a layout shift', 'INTEGER', FALSE, TRUE) +) x; + diff --git a/sqlpage/templates/card.handlebars b/sqlpage/templates/card.handlebars index c9c2da538..aa64fc471 100644 --- a/sqlpage/templates/card.handlebars +++ b/sqlpage/templates/card.handlebars @@ -38,7 +38,7 @@ {{/if}} {{#if top_image}} - + {{/if}} {{#if color}} {{#if (not embed)}} From a229d57e5c095b0cf9700d0cc49de1b102283e15 Mon Sep 17 00:00:00 2001 From: Ophir LOJKINE Date: Tue, 12 May 2026 17:38:24 +0200 Subject: [PATCH 2/2] docs: move card image parameters into existing migration --- .../sqlpage/migrations/31_card_docs_update.sql | 3 +++ .../sqlpage/migrations/75_card_top_image_attributes.sql | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 examples/official-site/sqlpage/migrations/75_card_top_image_attributes.sql diff --git a/examples/official-site/sqlpage/migrations/31_card_docs_update.sql b/examples/official-site/sqlpage/migrations/31_card_docs_update.sql index b010034d7..13909489b 100644 --- a/examples/official-site/sqlpage/migrations/31_card_docs_update.sql +++ b/examples/official-site/sqlpage/migrations/31_card_docs_update.sql @@ -18,6 +18,9 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S This is useful if you want to display a lot of text in the card, with many options for formatting, such as line breaks, **bold**, *italics*, lists, #titles, [links](target.sql), ![images](photo.jpg), etc.', 'TEXT', FALSE, TRUE), ('top_image', 'The URL (absolute or relative) of an image to display at the top of the card.', 'URL', FALSE, TRUE), + ('top_image_lazy', 'Whether the top image must be lazily loaded. Defaults to false, meaning eagerly loaded.', 'BOOLEAN', FALSE, TRUE), + ('top_image_width', 'Specify the top image width, in pixels. Helps prevent layout shifts.', 'INTEGER', FALSE, TRUE), + ('top_image_height', 'Specify the top image height, in pixels. Helps prevent layout shifts.', 'INTEGER', FALSE, TRUE), ('footer', 'Muted text to display at the bottom of the card.', 'TEXT', FALSE, TRUE), ('footer_md', 'Muted text to display at the bottom of the card, with rich text formatting in Markdown format.', 'TEXT', FALSE, TRUE), ('link', 'An URL to which the user should be taken when they click on the card.', 'URL', FALSE, TRUE), diff --git a/examples/official-site/sqlpage/migrations/75_card_top_image_attributes.sql b/examples/official-site/sqlpage/migrations/75_card_top_image_attributes.sql deleted file mode 100644 index 35ed3113a..000000000 --- a/examples/official-site/sqlpage/migrations/75_card_top_image_attributes.sql +++ /dev/null @@ -1,7 +0,0 @@ -INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'card', * FROM (VALUES - -- item level - ('top_image_lasy', 'Whether the top image must be lazily or eagerly loaded. Defaults to false, meaning eagerly', 'BOOLEAN', FALSE, TRUE), - ('top_image_width', 'Specify the top image width, in pixel. Help preventing a layout shift', 'INTEGER', FALSE, TRUE), - ('top_image_height', 'Specify the top image height, in pixel. Help preventing a layout shift', 'INTEGER', FALSE, TRUE) -) x; -