5 * Hooks provided by video_embed_field.
9 * Preprocess video iframes.
11 * For video providers that use the "video_embed_iframe" element, you can
12 * preprocess the element to access the individual components which make up the
14 * - url: The URL of the iframe, excluding the query parameters.
15 * - query: Individually manipulatable query string parameters.
16 * - attributes: The attributes on the iframe HTML element.
17 * - provider: The provider which has rendered the iframe, available for
18 * conditional logic only, should not be changed.
20 function hook_preprocess_video_embed_iframe(&$variables) {
21 // Add a class to all iframes that point to vimeo.
22 if ($variables['provider'] == 'vimeo') {
23 $variables['attributes']['class'][] = 'vimeo-embed';
28 * Preprocess iframes in the format of preprocess_video_embed_iframe__PROVIDER.
30 * Allows you to preprocess video embed iframes but only for specific providers.
31 * This allows you to, for instance control things specific to each provider.
32 * For example, if you wanted to enable a specific youtube feature by altering
33 * the query string, you could do so as demonstrated.
35 function hook_preprocess_video_embed_iframe__youtube(&$variables) {
36 // Remove the YouTube logo from youtube embeds.
37 $variables['query']['modestbranding'] = '1';
41 * Alter the video_embed_field plugin definitions.
43 * This hook allows you alter the plugin definitions managed by ProviderManager.
44 * This could be useful if you wish to remove a particular definition or perhaps
45 * replace one with your own implementation (as demonstrated).
47 function hook_video_embed_field_provider_info_alter(&$definitions) {
48 // Replace the YouTube provider class with another implementation.
49 $definitions['youtube']['class'] = 'Drupal\my_module\CustomYouTubeProvider';