Image Schema only works with image var in twig

Created on 15 October 2024, 8 months ago

Overview

Currently there is a bug that makes it so only one image reference per component can be used. This is because the $ref for images only applies to the image variable in twig, and doesn't apply based on the prop name.

Here is the YouTube video I made showcasing this issue:
https://youtu.be/CYmQK6bBLxM

This seems like a pretty fundamental issue to me so I'm marking it as critical for now.

Proposed resolution

User interface changes

🐛 Bug report
Status

Needs review

Version

0.0

Component

Page builder

Created by

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

Comments & Activities

  • Issue created by @jacobadeutsch
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    Moving to active.

  • Status changed to Postponed: needs info 7 days ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Can you still reproduce this? And if so, can you please provide the SDC that reproduces this as a patch, an MR or a link to a repo? 🙏 That's way easier for us to reproduce than watching this video 😇

    This is because the $ref for images only applies to the image variable in twig, and doesn't apply based on the prop name.

    That'd surprise me a lot, because the logic that 📌 Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed introduced definitely does not look at the name of the prop. It was introduced in August 2024 (months before this bug report) and is still unchanged today:

          JsonSchemaType::OBJECT => match (TRUE) {
            array_key_exists('$ref', $schema) => match ($schema['$ref']) {
              // @see \Drupal\image\Plugin\Field\FieldType\ImageItem
              // @see media_library_storage_prop_shape_alter()
              'json-schema-definitions://experience_builder.module/image' => new StorablePropShape(shape: $shape, fieldWidget: 'image_image', fieldTypeProp: new FieldTypeObjectPropsExpression('image', [
                'src' => new ReferenceFieldTypePropExpression(
                  new FieldTypePropExpression('image', 'entity'),
                  new FieldPropExpression(EntityDataDefinition::create('file'), 'uri', NULL, 'url'),
                ),
                'alt' => new FieldTypePropExpression('image', 'alt'),
                'width' => new FieldTypePropExpression('image', 'width'),
                'height' => new FieldTypePropExpression('image', 'height'),
              ])),
              default => NULL,
            },
            default => NULL,
          },
    

    + \Drupal\experience_builder\Hook\ShapeMatchingHooks::mediaLibraryStoragePropShapeAlter().

  • 🇫🇮Finland lauriii Finland

    I can't reproduce this anymore. Back in October we had a myriad of media related bugs so this could have been fixed by one of those.

Production build 0.71.5 2024