You are here

function hook_oembed_resource_url_alter in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/media.api.php \hook_oembed_resource_url_alter()
  2. 9 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
Hooks related to Media and its plugins.

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']);
  }
}