By chris burge on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
8.9.x
Introduced in version:
8.9.0
Issue links:
Description:
Drupal 8.9.0 introduces a new hook, hook_oembed_providers_alter(), which allows modules to programmatically alter the oEmbed provider list used by Media. The provider list is a pre-cache array of oEmbed providers. This hook fires before \Drupal\media\OEmbed\Provider objects are generated from the provider list.
function hook_oembed_providers_alter(array &$providers) {
// Add a custom provider.
$providers[] = [
'provider_name' => 'Custom Provider',
'provider_url' => 'http://custom-provider.example.com',
'endpoints' => [
[
'schemes' => [
'http://custom-provider.example.com/id/*',
'https://custom-provider.example.com/id/*',
],
'url' => 'https://custom-provider.example.com/api/v2/oembed/',
'discovery' => 'true',
],
],
];
}
This hook is useful in instances where a developer needs to add a provider that is not listed by http://oembed.com/providers.json. A developer also may use it to remove providers listed by http://oembed.com/providers.json.
Impacts:
Module developers