Skip to content
Snippets Groups Projects
Commit d3a449ff authored by Benni Mack's avatar Benni Mack Committed by Wouter Wolters
Browse files

[BUGFIX] Allow OnlineMedia Renderers to override via Fluid

When using the Online Media (Youtube / Vimeo) then the autoplay
option is always taken from the FileReference, overriding
the option that might be set via Fluid.

A check if the option hasn't been set yet makes the overriding
order clearer.

Resolves: #73484
Releases: master, 7.6
Change-Id: I3fb57c88383445062f5beabd8d8287ff772974d3
Reviewed-on: https://review.typo3.org/46712


Reviewed-by: default avatarDaniel Gorges <daniel.gorges@b13.de>
Tested-by: default avatarDaniel Gorges <daniel.gorges@b13.de>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
parent 690d2e6f
Branches
Tags
No related merge requests found
......@@ -89,7 +89,8 @@ class VimeoRenderer implements FileRendererInterface
*/
public function render(FileInterface $file, $width, $height, array $options = null, $usedPathsRelativeToCurrentScript = false)
{
if ($file instanceof FileReference) {
// Check for an autoplay option at the file reference itself, if not overriden yet.
if (!isset($options['autoplay']) && $file instanceof FileReference) {
$autoplay = $file->getProperty('autoplay');
if ($autoplay !== null) {
$options['autoplay'] = $autoplay;
......
......@@ -89,7 +89,8 @@ class YouTubeRenderer implements FileRendererInterface
*/
public function render(FileInterface $file, $width, $height, array $options = null, $usedPathsRelativeToCurrentScript = false)
{
if ($file instanceof FileReference) {
// Check for an autoplay option at the file reference itself, if not overriden yet.
if (!isset($options['autoplay']) && $file instanceof FileReference) {
$autoplay = $file->getProperty('autoplay');
if ($autoplay !== null) {
$options['autoplay'] = $autoplay;
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Rendering;
*/
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\VimeoHelper;
use TYPO3\CMS\Core\Resource\Rendering\VimeoRenderer;
use TYPO3\CMS\Core\Tests\UnitTestCase;
......@@ -123,6 +124,25 @@ class VimeoRendererTest extends UnitTestCase
);
}
/**
* @test
*/
public function renderOutputWithAutoplayFromReferenceIsCorrect()
{
/** @var File|\PHPUnit_Framework_MockObject_MockObject $fileResourceMock */
$fileResourceMock = $this->getMock(File::class, array(), array(), '', false);
/** @var FileReference|\PHPUnit_Framework_MockObject_MockObject $fileResourceMock */
$fileReferenceMock = $this->getMock(FileReference::class, array(), array(), '', false);
$fileReferenceMock->expects($this->any())->method('getProperty')->will($this->returnValue(1));
$fileReferenceMock->expects($this->any())->method('getOriginalFile')->willReturn($fileResourceMock);
$this->assertSame(
'<iframe src="//player.vimeo.com/video/7331?autoplay=1&amp;title=0&amp;byline=0&amp;portrait=0" allowfullscreen width="300" height="200"></iframe>',
$this->subject->render($fileReferenceMock, '300m', '200')
);
}
/**
* @test
*/
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Rendering;
*/
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\YouTubeHelper;
use TYPO3\CMS\Core\Resource\Rendering\YouTubeRenderer;
use TYPO3\CMS\Core\Tests\UnitTestCase;
......@@ -126,6 +127,26 @@ class YouTubeRendererTest extends UnitTestCase
);
}
/**
* @test
*/
public function renderOutputWithAutoplayFromFileReferenceIsCorrect()
{
/** @var File|\PHPUnit_Framework_MockObject_MockObject $fileResourceMock */
$fileResourceMock = $this->getMock(File::class, array(), array(), '', false);
/** @var FileReference|\PHPUnit_Framework_MockObject_MockObject $fileResourceMock */
$fileReferenceMock = $this->getMock(FileReference::class, array(), array(), '', false);
$fileReferenceMock->expects($this->any())->method('getProperty')->will($this->returnValue(1));
$fileReferenceMock->expects($this->any())->method('getOriginalFile')->willReturn($fileResourceMock);
$this->assertSame(
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;autoplay=1&amp;enablejsapi=1&amp;origin=test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
$this->subject->render($fileReferenceMock, '300m', '200')
);
}
/**
* @test
*/
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment