Skip to content

Commit ca24276

Browse files
smulvihillsylus
authored andcommitted
Issue #3279276 by smulvih2: WET media player
1 parent d80a0cd commit ca24276

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{#
2+
/**
3+
* @file
4+
* Theme override for a field.
5+
*
6+
* To override output, copy the "field.html.twig" from the templates directory
7+
* to your theme's directory and customize it, just like customizing other
8+
* Drupal templates such as page.html.twig or node.html.twig.
9+
*
10+
* Instead of overriding the theming for all fields, you can also just override
11+
* theming for a subset of fields using
12+
* @link themeable Theme hook suggestions. @endlink For example,
13+
* here are some theme hook suggestions that can be used for a field_foo field
14+
* on an article node type:
15+
* - field--node--field-foo--article.html.twig
16+
* - field--node--field-foo.html.twig
17+
* - field--node--article.html.twig
18+
* - field--field-foo.html.twig
19+
* - field--text-with-summary.html.twig
20+
* - field.html.twig
21+
*
22+
* Available variables:
23+
* - attributes: HTML attributes for the containing element.
24+
* - label_hidden: Whether to show the field label or not.
25+
* - title_attributes: HTML attributes for the title.
26+
* - label: The label for the field.
27+
* - multiple: TRUE if a field can contain multiple items.
28+
* - items: List of all the field items. Each item contains:
29+
* - attributes: List of HTML attributes for each item.
30+
* - content: The field item's content.
31+
* - entity_type: The entity type to which the field belongs.
32+
* - field_name: The name of the field.
33+
* - field_type: The type of the field.
34+
* - label_display: The display settings for the label.
35+
*
36+
* @ingroup templates
37+
*
38+
* @see template_preprocess_field()
39+
*/
40+
#}
41+
42+
<figure class="wb-mltmd" data-wb-mltmd='{"shareUrl": "{{ video_url }}"}'>
43+
<video title="{{ video_title }}">
44+
<source type="video/youtube" src="{{ video_url }}" />
45+
</video>
46+
<figcaption>
47+
<p>{{ video_title }}</p>
48+
</figcaption>
49+
</figure>

wxt_bootstrap.theme

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,14 @@ function wxt_bootstrap_preprocess_filter_caption(&$variables) {
163163
$variables['show_caption'] = TRUE;
164164
}
165165
}
166+
167+
/**
168+
* Implements hook_preprocess_field().
169+
*/
170+
function wxt_bootstrap_preprocess_field(&$variables) {
171+
if ($variables['element']['#bundle'] == 'remote_video') {
172+
// Get title and URL of remote video.
173+
$variables['video_title'] = $variables['element'][0]['#attributes']['title'];
174+
$variables['video_url'] = $variables['element']['#items'][0]->getValue()['value'];
175+
}
176+
}

0 commit comments

Comments
 (0)