From 526f1795a641a844b1831b50923d500a1b1d0ba2 Mon Sep 17 00:00:00 2001 From: Markus Sommer <markussom@posteo.de> Date: Thu, 29 Jun 2017 16:36:16 +0200 Subject: [PATCH] [TASK] Reenable all additionals in video tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- .../Resource/Rendering/VideoTagRenderer.php | 11 +++++++++++ .../Rendering/VideoTagRendererTest.php | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php b/typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php index d779493af0fa..3408234b23cd 100644 --- a/typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php +++ b/typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php @@ -104,12 +104,23 @@ class VideoTagRenderer implements FileRendererInterface 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), diff --git a/typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php b/typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php index 306a383f14dc..40bfeee0ba78 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php @@ -104,6 +104,24 @@ class VideoTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas '//: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>', ] ]; } -- GitLab