Create an Image SDC that can be included by other SDCs

Created on 11 July 2025, 2 months ago

Overview

Provide an SDC component to render a responsive image that can be included by other components. It should not be visible as an available component in the editor, but should be usable by component authors in their own SDCs. To demonstrate this, additionally provide a basic SDC card component example in one of the testing modules.

Proposed resolution

Create a component that is usable in roughly the following way:

{{ include('image', {
  ...image,
  class: 'max-content',
  fill: true,
  sizes: '(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw' })
}}
{{ include('image', {
  src: './gracie.jpg',
  alt: 'Gracie is awesome',
  class: 'max-content',
  fill: true,
  sizes: '(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw'
})}}
{{ include('image', {
  src: 'https://placehold.co/3000x3000/png',
  alt: 'Placeholder image',
  sizes: 'auto 100vw'
})}}
{{ include('image', {
  src: node.field_content_image.get(0).url,
  alt: node.field_content_image.get(0).alt,
  width: node.field_content_image.get(0).width,
  height: node.field_content_image.get(0).height,
  class: 'max-content',
  fill: true,
  sizes: '(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw'
})}}
šŸ“Œ Task
Status

Active

Version

0.0

Component

Component sources

Created by

šŸ‡¬šŸ‡§United Kingdom justafish London, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024