Problem/Motivation
Quoting @seanb from Jan 7, 2018:
Discussed the link dependency with chr.fritsch in slack. We agreed link fields are best suited to store the links to oEmbed media. String fields are currently also allowed as a source field and we should probably remove that. Any thoughts?
— #2831944-66: Implement media source plugin for remote video via oEmbed
The link or uri field types would be more suitable.
Then, in #2831944-67: Implement media source plugin for remote video via oEmbed, @chr.fritsch removed string and kept only link.
Finally, in #2831944-77 through -83, @alexpott, @chr.fritsch, @phenaproxima, @dawehner and @samuel.mortenson went back and forth what the best approach is. Considerations were:
- limiting dependencies (not requiring the Link module)
- predictability (same field type used on all sites)
- no impact on UX anyway (since the media source field would not be populated using the default widget for the media source field's field type anyway, and for presenting, the oEmbed formatter would be used anyway — which notably and AFAICT unintentionally still supports the
linkfield type! 😅)
… and hence string was chosen.
(I'm not sure why \Drupal\Core\Field\Plugin\Field\FieldType\UriItem was not considered? 🤔🤷)
But, this did not consider one aspect that was perhaps irrelevant, but is relevant now: metadata/Typed Data!
The consequence is that it is impossible to fetch the oEmbed URL or oEmbed XML/JSON blob for any oEmbed Media entities. All you can get is the URL originally entered by the content author (e.g. https://giphy.com/gifs/service-department-customer-T8Dhl1KPyzRqU) and it is impossible to retrieve the corresponding resource to actually display to visitors (e.g. https://media3.giphy.com/media/T8Dhl1KPyzRqU/giphy.gif).
⚠️ This makes it impossible for https://drupal.org/project/canvas to pass the structured data of oEmbed media items to components.
Steps to reproduce
N/A
Proposed resolution
Use a new field type that provides access to relevant oEmbed information via Typed Data properties.
Rough proposal:
introduce OEmbedUriItem extends \Drupal\Core\Field\Plugin\Field\FieldType\UriItem, with:
- the existing
valueproperty being what the user would've entered - a computed
typeproperty to be one of\Drupal\media\OEmbed\Resource::TYPE_* - a computed
resourceproperty to pass along the results for\Drupal\media\OEmbed\ResourceFetcher::createResource() - a computed
urlproperty to pass along the results for\Drupal\media\OEmbed\UrlResolver::getResourceUrl()
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3567249
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 leersCiting from #3550750's https://git.drupalcode.org/project/canvas/-/merge_requests/400:
This is that issue.
Comment #3
quietone commented