More tidying.
[yaffs-website] / web / modules / contrib / video_embed_field / video_embed_field.api.php
1 <?php
2
3 /**
4  * @file
5  * Hooks provided by video_embed_field.
6  */
7
8 /**
9  * Preprocess video iframes.
10  *
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
13  * iframe including:
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.
19  */
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';
24   }
25 }
26
27 /**
28  * Preprocess iframes in the format of preprocess_video_embed_iframe__PROVIDER.
29  *
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.
34  */
35 function hook_preprocess_video_embed_iframe__youtube(&$variables) {
36   // Remove the YouTube logo from youtube embeds.
37   $variables['query']['modestbranding'] = '1';
38 }
39
40 /**
41  * Alter the video_embed_field plugin definitions.
42  *
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).
46  */
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';
50 }