function MediaTestOembedThemeHooks::preprocessMediaOembedIframe

Implements hook_preprocess_media_oembed_iframe().

Attributes

#[Hook('preprocess_media_oembed_iframe')]

File

core/modules/media/tests/modules/media_test_oembed/src/Hook/MediaTestOembedThemeHooks.php, line 17

Class

MediaTestOembedThemeHooks
Theme hook implementations for media_test_oembed.

Namespace

Drupal\media_test_oembed\Hook

Code

public function preprocessMediaOembedIframe(array &$variables) : void {
  if ($variables['resource']->getProvider()
    ->getName() === 'YouTube') {
    $variables['media'] = str_replace('?feature=oembed', '?feature=oembed&pasta=rigatoni', (string) $variables['media']);
  }
  // @see \Drupal\Tests\media\Kernel\OEmbedIframeControllerTest
  $variables['#attached']['library'][] = 'media_test_oembed/frame';
  $variables['#cache']['tags'][] = 'yo_there';
}

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