function hook_oembed_resource_url_alter

Same name in other branches
  1. 8.9.x core/modules/media/media.api.php \hook_oembed_resource_url_alter()
  2. 10 core/modules/media/media.api.php \hook_oembed_resource_url_alter()
  3. 11.x core/modules/media/media.api.php \hook_oembed_resource_url_alter()

Alters an oEmbed resource URL before it is fetched.

Parameters

array $parsed_url: A parsed URL, as returned by \Drupal\Component\Utility\UrlHelper::parse().

\Drupal\media\OEmbed\Provider $provider: The oEmbed provider for the resource.

See also

\Drupal\media\OEmbed\UrlResolverInterface::getResourceUrl()

Related topics

1 function implements hook_oembed_resource_url_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

media_test_oembed_oembed_resource_url_alter in core/modules/media/tests/modules/media_test_oembed/media_test_oembed.module
Implements hook_oembed_resource_url_alter().
1 invocation of hook_oembed_resource_url_alter()
UrlResolver::getResourceUrl in core/modules/media/src/OEmbed/UrlResolver.php
Builds the resource URL for a media asset URL.

File

core/modules/media/media.api.php, line 33

Code

function hook_oembed_resource_url_alter(array &$parsed_url, \Drupal\media\OEmbed\Provider $provider) {
    // Always serve YouTube videos from youtube-nocookie.com.
    if ($provider->getName() === 'YouTube') {
        $parsed_url['path'] = str_replace('://youtube.com/', '://youtube-nocookie.com/', $parsed_url['path']);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.