[beta1] Replace calls to /themes/contrib/ui_suite_dsfr/ by data URI in previews

Created on 10 February 2023, over 1 year ago
Updated 14 March 2023, over 1 year ago

Problem/Motivation

Some preview properties hardcode the full path to the image. Example:

  fields:
    image:
      type: render
      label: Image
      description: Card image render. Optional.
      preview:
        theme: image
        uri: "themes/contrib/ui_suite_dsfr/assets/card-image.svg"

This path is very common, but it is possible to have an other one like:

  • themes/ui_suite_dsfr/assets/card-image.svg
  • themes/foo/bar/ui_suite_dsfr/assets/card-image.svg
  • profiles/foo/themes/ui_suite_dsfr/assets/card-image.svg
  • ...

Proposed resolution

Replace the path by a data URI, like what was done for Bootstrap5:

  fields:
    image:
      type: "render"
      label: "Image"
      description: "Card image."
      preview:
        - theme: "image"
          uri: "data:image/svg+xml;base64,PHN2..."

Source: https://git.drupalcode.org/project/ui_suite_bootstrap/-/blob/5.0.x/templ...

Keep the original images in asset/ even if they are not used anymore.

πŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡«πŸ‡·France pdureau Paris

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

Comments & Activities

Production build 0.69.0 2024