Problem/Motivation
Currently, when https://oembed.com/providers.json
is fetched to generate a list of available oEmbed providers, there is no opportunity to alter the list of providers.
This would be useful in scenarios such as 1) Peer Tube and 2) oEmbed providers that may be organization-specific. Peer Tube is a decentralized video platform. The user can search videos across multiple instance of PeerTube with different domain names. Re custom oEmbed providers, the University of Nebraska-Lincoln hosts its own video service, which will soon support oEmbed. This functionality is needed by this organization.
Proposed resolution
Provide hook_oembed_providers_alter()
. (Media already provides hook_oembed_resource_url_alter()
).
Remaining tasks
Submit patchTests pass- Subsystem maintainer review
Change record
User interface changes
None.
API changes
Adding hook_oembed_providers_alter()
.
Data model changes
None.
Release notes snippet
TBD
Original report by phjou
I have studied the code from the oEmbed system in the core and I have discovered that it is based on the list provided by https://oembed.com/providers.json
This is a good list to start but I am wondering how to add a provider to this list?
You can host a new file with the additional services and change the settings "oembed_providers_url". But this method is really complicated to just support more providers.Moreover I am creating this issue in order to support PeerTube which is a decentralized video platform. The user can search videos across multiple instance of PeerTube with different domain names. Such a complicated way to support a new provider is just impossible for a simple contributor.
In order to resolve this problem:
- The user should be able to override the default URL. The issue already exists for another reason: #2999018
- We should be able to alter the provider list by using a hook. What do you think about adding an alter call in the getAll function from Drupal\media\OEmbed\ProviderRepository?