Skip to main content
Penyaskito Blog

Main navigation

  • Home
Language switcher
  • English
  • Español
User account menu
  • Log in

Breadcrumb

  1. Home

Canvas Tips&Tricks: Declaring images in SDCs

By penyaskito , 18 July, 2026

I've read recently about making SDCs dependent on Drupal Canvas because of needing to reference Canvas in the definition of your prop, so the right media widget is used inside Canvas:

image:
  $ref: json-schema-definitions://canvas.module/image
  type: object
  title: Image
  description: >
    Image of the singer
  examples:
    - src: 'micro.webp'
      alt: 'Nice picture of the singer'
      width: 200
      height: 300

That was the case during the alphas. But was fixed long ago, even before the 1.0.0 release. See canvas#3515074.

image:
  type: object
  title: Image
  required: [src]
  properties:
    src:
      type: string
      format: uri-reference
      contentMediaType: "image/*"
      x-allowed-schemes: [http, https]   # this is image-uri, itself a nested $ref
    alt:    { type: string }
    width:  { type: integer }
    height: { type: integer }
  description: >
    Image of the singer
  examples:
    - src: 'micro.webp'
      alt: 'Nice picture of the singer'
      width: 200
      height: 300

That's more verbose, but would make your SDC Canvas-independent and re-usable, and it's 100% equivalent. 

If we missed updating some docs, please create an issue on the Canvas issue queue.

Tags

  • Drupal
  • Drupal Canvas
  • Drupal Canvas Tips&Tricks
  • Single-Directory Components
  • Drupal planet

Comments

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Monthly archive

  • July 2026 (3)
  • April 2026 (4)
  • August 2025 (1)
  • April 2025 (1)
  • July 2023 (1)
  • December 2021 (1)
  • May 2021 (2)
  • April 2021 (1)
  • September 2014 (1)
  • November 2012 (1)
  • September 2012 (2)
  • August 2012 (3)
  • June 2012 (6)

Recent content

Canvas Tips&Tricks: Declaring images in SDCs
4 hours ago
Canvas Internals - JSON data types in different databases: It works on my machine!
2 weeks ago
Quarterly Contributions summary for 2026 Q2
2 weeks 1 day ago

Recent comments

That's a great idea! I would…
3 months ago
D.org integration
3 months ago
Can't blame you 😜For me…
3 months ago

Blogs I follow

  • Mateu Aguiló "e0ipso"
  • Gábor Hojtsy
  • Pedro Cambra
  • The Russian Lullaby, davidjguru
  • Can It Be All So Simple
  • Maria Arias de Reyna "Délawen"
  • Matt Glaman
  • Daniel Wehner
  • Jacob Rockowitz
  • Wim Leers
  • Dries Buytaert
  • arcturus
  • Drupal Core AI digest
  • Drupal CMS AI digest
  • Drupal Canvas AI digest
  • Drupal AI AI digest
  • Drupal Patterns AI digest
  • Trisha Gee
  • Très Bien Tech, by _nod
  • Moshe Weitzman
  • Drupal core change records
  • Ed Zitron's Where's Your Ed At
  • Sebastian Bergmann (phpunit.expert)
  • PHP Reads
  • mandclu
  • Marissa Epstein
  • WordPress Core
  • David Bushell
Syndicate

Footer

  • Drupal.org
  • LinkedIn
  • GitHub
  • Mastodon
  • Twitter
Powered by Drupal

Free 🇵🇸