[FEATURE] HTML5 video poster preview image 08/41608/5
authorMichael Oehlhof <typo3@oehlhof.de>
Fri, 17 Jul 2015 20:42:12 +0000 (22:42 +0200)
committerBenni Mack <benni@typo3.org>
Thu, 13 Aug 2015 18:49:27 +0000 (20:49 +0200)
Enable Video preview image "poster" in media in the old fashion way.
If there is a jpg, jpeg or png image in the same folder with the same
name as the video file it will be added with the HTML5 poster attribute.

The file extensions are checked exactly in the order mentioned above.

Resolves: #63395
Releases: master
Change-Id: Ie1008d1d7c2b5cff90a5ad33886e37a06417c568
Reviewed-on: http://review.typo3.org/41608
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Documentation/Changelog/master/Feature-63395-Html5VideoPosterPreviewImage.rst [new file with mode: 0644]
typo3/sysext/mediace/Classes/ContentObject/FlowPlayerContentObject.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-63395-Html5VideoPosterPreviewImage.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-63395-Html5VideoPosterPreviewImage.rst
new file mode 100644 (file)
index 0000000..f33d503
--- /dev/null
@@ -0,0 +1,13 @@
+==================================================
+Feature: #63395 - HTML5 video poster preview image
+==================================================
+
+Description
+===========
+
+Enable Video preview image "poster" in media in the old fashion way.
+
+If there is a jpg, jpeg or png image in the same folder with the same
+name as the video file it will be shown with the HTML5 poster attribute.
+
+The file extensions are checked exactly in the order mentioned above.
index bf05528..4859c38 100644 (file)
@@ -415,6 +415,16 @@ class FlowPlayerContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstract
                $alternativeContent = isset($conf['alternativeContent.']) ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.']) : $conf['alternativeContent'];
                // Render video
                if ($conf['type'] === 'video') {
+                       // add preview image, html5 poster attribute
+                       $sourceBasePath = substr($conf['sources'][1], 0, strrpos($conf['sources'][1], '.'));
+                       foreach (['.jpg', '.jpeg', '.png'] as $fileExtension) {
+                               $posterFilePath = $GLOBALS['TSFE']->tmpl->getFileName($sourceBasePath . $fileExtension);
+                               if (file_exists($posterFilePath)) {
+                                       $attributes .= ' poster="' . htmlspecialchars($posterFilePath) . '"';
+                                       break;
+                               }
+                       }
+
                        if ($conf['preferFlashOverHtml5']) {
                                // Flash with video tag fallback
                                $conf['params.']['playerFallbackOrder'] = array('flash', 'html5');