Overview
#3530351: Decouple image+video (URI) shape matching from specific image+video file types/extensions is about avoiding assumptions in the shape definition about specific image file types.
#3530521: Decouple image shape matching from the `image` MediaType: support matching multiple bundles of a single MediaSources (`image`) is about avoiding assumptions in XB's shape matching that require/assume the Standard install profile's image media type.
This is about avoiding assumptions in XB's shape matching that require/assume a single MediaSource plugin — for example it should be possible to automatically pick from both locally uploaded images (the image MediaType powered by core's Image MediaSource) and remote ones (by enabling the disabled-by-default Flickr oEmbed provider, creating a new flickr MediaType powered by the oEmbed provider
Proposed resolution
- Expand the test coverage in
MediaLibraryHookStoragePropAlterTest— requires something like this:
diff --git a/core/modules/media/src/Plugin/media/Source/OEmbedDeriver.php b/core/modules/media/src/Plugin/media/Source/OEmbedDeriver.php index bdbc5355617..dc3bed29302 100644 --- a/core/modules/media/src/Plugin/media/Source/OEmbedDeriver.php +++ b/core/modules/media/src/Plugin/media/Source/OEmbedDeriver.php @@ -28,6 +28,13 @@ public function getDerivativeDefinitions($base_plugin_definition) { 'providers' => ['YouTube', 'Vimeo'], 'default_thumbnail_filename' => 'video.png', ] + $base_plugin_definition, + 'image' => [ + 'id' => 'image', + 'label' => $this->t('Remote image'), + 'description' => $this->t('Use remote video URL for reusable media.'), + 'providers' => ['Flickr'], + 'default_thumbnail_filename' => 'image.png', + ] + $base_plugin_definition, ]; return parent::getDerivativeDefinitions($base_plugin_definition); }+
langcode: en status: true dependencies: { } id: remote_image label: 'Remote image' description: 'A remotely hosted image from Flickr.' source: 'oembed:image' queue_thumbnail_downloads: false new_revision: true source_configuration: source_field: field_media_oembed_image thumbnails_directory: 'public://oembed_thumbnails/[date:custom:Y-m]' providers: - Flickr field_map: {} #TBD - For reference, e.g. https://www.flickr.com/photos/educowebdesign/48754730203/ can be oEmbed-fetched using https://www.flickr.com/services/oembed/?url=https://www.flickr.com/photo..., which returns currently:
<oembed> <type>photo</type> <flickr_type>photo</flickr_type> <title>IMG_8638</title> <author_name>EDUCO Web Design</author_name> <author_url>https://www.flickr.com/photos/educowebdesign/</author_url> <width>1024</width> <height>683</height> <url>https://live.staticflickr.com/65535/48754730203_d15ec76ff6_b.jpg</url> <web_page>https://www.flickr.com/photos/educowebdesign/48754730203/</web_page> <thumbnail_url>https://live.staticflickr.com/65535/48754730203_d15ec76ff6_q.jpg</thumbnail_url> <thumbnail_width>150</thumbnail_width> <thumbnail_height>150</thumbnail_height> <web_page_short_url>https://flic.kr/p/2hhhJGB</web_page_short_url> <license>All Rights Reserved</license> <license_id>0</license_id> <html><a data-flickr-embed="true" href="https://www.flickr.com/photos/educowebdesign/48754730203/" title="IMG_8638 by EDUCO Web Design, on Flickr"><img src="https://live.staticflickr.com/65535/48754730203_d15ec76ff6_b.jpg" width="1024" height="683" alt="IMG_8638"></a><script async src="https://embedr.flickr.com/assets/client-code.js" charset="utf-8"></script></html> <version>1.0</version> <cache_age>3600</cache_age> <provider_name>Flickr</provider_name> <provider_url>https://www.flickr.com/</provider_url> </oembed> - Update the logic in
\Drupal\experience_builder\Hook\ShapeMatchingHooks::mediaLibraryStoragePropShapeAlter()to account for not only different field names, but also different prop names
… and perhaps more than that — depending on how different the shape is, this may need to add per-target bundle support to more\Drupal\experience_builder\PropExpressions\StructuredData\*infrastructure - Expand test coverage at
\Drupal\Tests\experience_builder\Kernel\PropSourceTest::providerStaticPropSource()— see thecomplex non-empty example with entity_reference and multiple target bundles but same field nametest case added by #3530521: Decouple image shape matching from the `image` MediaType: support matching multiple bundles of a single MediaSources (`image`). - Overall, read all the
ℹ️ …
remarks at https://git.drupalcode.org/project/experience_builder/-/merge_requests/1150, they should provide the necessary guidance 🤞
User interface changes
TBD
Issue fork experience_builder-3530533
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wim leersComment #3
wim leersComment #4
wim leersComment #5
wim leersThe MR for #3530521: Decouple image shape matching from the `image` MediaType: support matching multiple bundles of a single MediaSources (`image`) has landed — that provides all the examples necessary for developing, testing and debugging this issue's scope.
Comment #8
wim leersComment #9
penyaskitoNR per my comments, and Wim wanted to self-review.
With confirmation of my interpretation of the phpstan errors by Wim I think I could move this forward.
Comment #10
wim leersThis blocks #3519247: Acquia DAM and Canvas integration in https://www.drupal.org/project/acquia_dam.
Comment #11
wim leersReady for a new round of review! 🥳
Comment #12
wim leersThanks!
Comment #13
wim leersGiven the extra complexity this is bringing to prop expressions (to make them able to express more complex scenarios such as the one outlined in the issue summary), the importance of #3526716: Tighten validation of `experience_builder.generated_field_explicit_input_ux: prop_field_definitions.[%key].expression` became higher.
See #3526716-9: Tighten validation of `experience_builder.generated_field_explicit_input_ux: prop_field_definitions.[%key].expression`, where I'm picking that up :)
Comment #14
wim leers#3526716: Tighten validation of `experience_builder.generated_field_explicit_input_ux: prop_field_definitions.[%key].expression` is in 🥳
Comment #15
wim leersProven end-to-end that this enables multiple media sources to power image media in XB:

See #3519247-13: Acquia DAM and Canvas integration.
Comment #16
wim leersComment #18
wim leers