Skip to content

Commit

Permalink
[BUGFIX] Support embedding of private vimeo videos
Browse files Browse the repository at this point in the history
The video ID of a private vimeo video is appended
by a hash parameter. This tuple is stored in the
pseudo video file (*.vimeo) and needs to be respected
when rendering the iframe or fetching data via the
vimeo API.

Resolves: #97446
Releases: main, 12.4
Change-Id: Icbeac0552c5f78d2dc405ce58daae195c352195e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81070
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
Philipp Kitzberger authored and sbuerk committed Sep 20, 2023
1 parent ae4e1ba commit 1b29292
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion typo3/sysext/core/Classes/Resource/Rendering/VimeoRenderer.php
Expand Up @@ -127,8 +127,16 @@ protected function collectOptions(array $options, FileInterface $file)
*/
protected function createVimeoUrl(array $options, FileInterface $file)
{
$videoId = $this->getVideoIdFromFile($file);
$videoIdRaw = $this->getVideoIdFromFile($file);
$videoIdRaw = GeneralUtility::trimExplode('/', $videoIdRaw, true);

$videoId = $videoIdRaw[0];
$hash = $videoIdRaw[1] ?? null;

$urlParams = [];
if (!empty($hash)) {
$urlParams[] = 'h=' . $hash;
}
if (!empty($options['autoplay'])) {
$urlParams[] = 'autoplay=1';
// If autoplay is enabled, enforce muted=1, see https://developer.chrome.com/blog/autoplay/
Expand Down
Expand Up @@ -227,7 +227,7 @@ public function renderOutputWithPrivateVimeoCodeIsCorrect(): void
$fileResourceMock = $this->createMock(File::class);

self::assertSame(
'<iframe src="https://player.vimeo.com/video/7331/private0123?dnt=1&amp;title=0&amp;byline=0&amp;portrait=0" allowfullscreen width="300" height="200" allow="fullscreen"></iframe>',
'<iframe src="https://player.vimeo.com/video/7331?h=private0123&amp;dnt=1&amp;title=0&amp;byline=0&amp;portrait=0" allowfullscreen width="300" height="200" allow="fullscreen"></iframe>',
$subject->render($fileResourceMock, '300m', '200')
);
}
Expand All @@ -247,7 +247,7 @@ public function renderOutputIsEscaped(): void
$fileResourceMock = $this->createMock(File::class);

self::assertSame(
'<iframe src="https://player.vimeo.com/video/7331&lt;script&gt;danger&lt;/script&gt;&apos;&quot;random&quot;quotes;?dnt=1&amp;title=0&amp;byline=0&amp;portrait=0" allowfullscreen width="300" height="200" allow="fullscreen"></iframe>',
'<iframe src="https://player.vimeo.com/video/7331&lt;script&gt;danger&lt;?h=script&gt;&apos;&quot;random&quot;quotes;&amp;dnt=1&amp;title=0&amp;byline=0&amp;portrait=0" allowfullscreen width="300" height="200" allow="fullscreen"></iframe>',
$subject->render($fileResourceMock, '300m', '200')
);
}
Expand Down

0 comments on commit 1b29292

Please sign in to comment.