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

  1. 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
    
  2. 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> 
    
  3. 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
  4. Expand test coverage at \Drupal\Tests\experience_builder\Kernel\PropSourceTest::providerStaticPropSource() — see the complex non-empty example with entity_reference and multiple target bundles but same field name test case added by #3530521: Decouple image shape matching from the `image` MediaType: support matching multiple bundles of a single MediaSources (`image`).
  5. 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

Command icon 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

wim leers created an issue. See original summary.

wim leers’s picture

Title: Support image shape matching from the `image` MediaSource: support both the `image` + `oembed` MediaSources simultaneously » Support image shape against multiple MediaSources (`image` + `oembed`) simultaneously
Related issues: +#3530351: Decouple image+video (URI) shape matching from specific image+video file types/extensions, +#3530521: Decouple image shape matching from the `image` MediaType: support matching multiple bundles of a single MediaSources (`image`)
wim leers’s picture

Title: Support image shape against multiple MediaSources (`image` + `oembed`) simultaneously » Support image shape matching against multiple bundles of multiple MediaSources (`image` + `oembed`) simultaneously
wim leers’s picture

Title: Support image shape matching against multiple bundles of multiple MediaSources (`image` + `oembed`) simultaneously » Support image shape matching against multiple bundles of multiple MediaSources (`image` + `oembed`)
wim leers’s picture

Issue summary: View changes

The 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.

penyaskito made their first commit to this issue’s fork.

wim leers’s picture

Assigned: Unassigned » wim leers
penyaskito’s picture

Status: Active » Needs review

NR 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.

wim leers’s picture

wim leers’s picture

Assigned: wim leers » penyaskito

Ready for a new round of review! 🥳

wim leers’s picture

Assigned: penyaskito » wim leers

Thanks!

wim leers’s picture

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community
Related issues: +#3519247: Acquia DAM and Canvas integration

Proven end-to-end that this enables multiple media sources to power image media in XB:

See #3519247-13: Acquia DAM and Canvas integration.

wim leers’s picture

Title: Support image shape matching against multiple bundles of multiple MediaSources (`image` + `oembed`) » Support image shape matching against multiple bundles of multiple MediaSources (`image` + `oembed` + `acquia_dam_asset` + …)

  • wim leers committed b762b4a1 on 1.x
    Issue #3530533 by wim leers, penyaskito: Support image shape matching...
wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.