Skip to content

Commit

Permalink
[TASK] Reenable all additionals in video tag
Browse files Browse the repository at this point in the history
Enable all additionalAttributes and additionalConfig’s to cover w3c and special spacs.

Resolves: #81743, #81741
Releases: master, 8.7
Change-Id: Ibfce2bd66e6de95eeb7c05eab160eec40ae437ef
Reviewed-on: https://review.typo3.org/53356
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
Markus Sommer authored and bmack committed Feb 7, 2018
1 parent e993d07 commit 526f179
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,23 @@ public function render(FileInterface $file, $width, $height, array $options = []
if (!empty($options['loop'])) {
$attributes[] = 'loop';
}
if (is_array($options['additionalConfig'])) {
foreach ($options['additionalConfig'] as $key => $value) {
if ((bool)$value) {
$attributes[] = htmlspecialchars($key);
}
}
}

foreach (['class', 'dir', 'id', 'lang', 'style', 'title', 'accesskey', 'tabindex', 'onclick', 'controlsList'] as $key) {
if (!empty($options[$key])) {
$attributes[] = $key . '="' . htmlspecialchars($options[$key]) . '"';
}
}

// Clean up duplicate attributes
$attributes = array_unique($attributes);

return sprintf(
'<video%s><source src="%s" type="%s"></video>',
empty($attributes) ? '' : ' ' . implode(' ', $attributes),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ public function renderArgumentsDataProvider()
'//:path/myVideoFile',
['data' => ['js-required' => 'yes', 'custom-id' => 'video-123']],
'<video data-js-required="yes" data-custom-id="video-123" width="300" height="200" controls><source src="//:path/myVideoFile" type="video/mp4"></video>',
],
[
'//:path/myVideoFile',
[
'data' => [
'js-required' => 'yes',
'custom-id' => 'video-123'
],
'additionalAttributes' => [
'muted' => 'muted',
'foo' => 'bar'
],
'additionalConfig' => [
'playsinline' => '1',
'controls' => '1'
]
],
'<video muted="muted" foo="bar" data-js-required="yes" data-custom-id="video-123" width="300" height="200" controls playsinline><source src="//:path/myVideoFile" type="video/mp4"></video>',
]
];
}
Expand Down

0 comments on commit 526f179

Please sign in to comment.