Skip to content

Commit

Permalink
Another last minute fix. Wrong min height on Video
Browse files Browse the repository at this point in the history
Why did I refactor? Well, embargoes. Never forget.
This was inheriting some Audio CSS which is different
  • Loading branch information
DiegoPino authored Nov 27, 2021
1 parent 7af40f3 commit 1d2e51d
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Plugin/Field/FieldFormatter/StrawberryVideoFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$max_width_css = empty($max_width) || $max_width == 0 ? '100%' : $max_width .'px';
$max_height = $this->getSetting('max_height');
$max_height_css = empty($max_height) || $max_height == 0 ? 'auto' : $max_height .'px';
// Basically min 90px height if using VTT
$max_height_vtt_css = empty($max_height) || $max_height == 0 ? 'auto' : ($max_height <= 90 ? 90 : $max_height) .'px';

$current_language = $items->getEntity()->get('langcode')->value;
$nodeid = $items->getEntity()->id();
Expand Down Expand Up @@ -264,18 +266,11 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
*/
if (count($vtt)) {
// Yep, redundant but we have no longer these settings here
// and i need to add 30px (uff) to the top.

if ($max_height = $this->getSetting('max_height') <= 90) {
$max_width = $this->getSetting('max_width');
$max_height = 90;
$max_width_css = empty($max_width) || $max_width == 0 ? '100%' : $max_width . 'px';
}

foreach ($media as $drforkey => $media_item) {
if (isset($vtt[$drforkey])) {
foreach ($media_item as $key => $media_entry) {
$elements[$delta]['video_hmtl5_' . $key]['video']['#attributes']['style'] = "width:{$max_width_css}; height:{$max_height}px";
$elements[$delta]['video_hmtl5_' . $key]['video']['#attributes']['style'] = "width:{$max_width_css}; height:{$max_height_vtt_css}";
foreach ($vtt[$drforkey] as $vtt_key => &$vtt_item) {
$route_parameters = [
'node' => $nodeid,
Expand Down Expand Up @@ -379,7 +374,7 @@ protected function generateElementForItem(int $delta, FieldItemListInterface $it
'class' => ['field-av', 'video-av'],
'id' => 'video_' . $uniqueid,
'controls' => TRUE,
'style' => "width:{$max_width_css}; height:{$max_height_css}px",
'style' => "width:{$max_width_css}; height:{$max_height_css}",
],
'#alt' => $this->t(
'Audio for @label',
Expand All @@ -401,4 +396,4 @@ protected function generateElementForItem(int $delta, FieldItemListInterface $it
];
$elements[$delta]['#attached']['library'][] = 'format_strawberryfield/av_strawberry';
}
}
}

0 comments on commit 1d2e51d

Please sign in to comment.