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

Created on 10 February 2023, almost 2 years 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.71.5 2024