[TASK] Reenable all additionals in video tag 56/53356/3
authorMarkus Sommer <markussom@posteo.de>
Thu, 29 Jun 2017 14:36:16 +0000 (16:36 +0200)
committerBenni Mack <benni@typo3.org>
Wed, 7 Feb 2018 18:56:56 +0000 (19:56 +0100)
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>
typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php
typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php

index d779493..3408234 100644 (file)
@@ -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),
index 306a383..40bfeee 100644 (file)
@@ -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>',
             ]
         ];
     }