• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FluidTYPO3 / vhs / 13566190336

27 Feb 2025 12:18PM UTC coverage: 72.127% (-0.6%) from 72.746%
13566190336

push

github

NamelessCoder
[TER] 7.1.0

5649 of 7832 relevant lines covered (72.13%)

20.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.24
/Classes/ViewHelpers/Media/VimeoViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Media;
3

4
/*
5
 * This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10

11
use FluidTYPO3\Vhs\Traits\ArgumentOverride;
12
use FluidTYPO3\Vhs\Traits\TagViewHelperCompatibility;
13
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
14

15
/**
16
 * Renders HTML code to embed a video from Vimeo.
17
 */
18
class VimeoViewHelper extends AbstractTagBasedViewHelper
19
{
20
    use ArgumentOverride;
21
    use TagViewHelperCompatibility;
22

23
    /**
24
     * Base URL for Vimeo video player
25
     */
26
    const VIMEO_BASEURL = '//player.vimeo.com/video/';
27

28
    /**
29
     * @var string
30
     */
31
    protected $tagName = 'iframe';
32

33
    public function initializeArguments(): void
34
    {
35
        parent::initializeArguments();
7✔
36
        $this->registerUniversalTagAttributes();
7✔
37
        $this->registerArgument('videoId', 'string', 'Vimeo ID of the video to embed.', true);
7✔
38
        $this->registerArgument(
7✔
39
            'width',
7✔
40
            'integer',
7✔
41
            'Width of the video in pixels. Defaults to 640 for 16:9 content.',
7✔
42
            false,
7✔
43
            640
7✔
44
        );
7✔
45
        $this->registerArgument(
7✔
46
            'height',
7✔
47
            'integer',
7✔
48
            'Height of the video in pixels. Defaults to 360 for 16:9 content.',
7✔
49
            false,
7✔
50
            360
7✔
51
        );
7✔
52
        $this->overrideArgument('title', 'boolean', 'Show the title on the video. Defaults to TRUE.', false, true);
7✔
53
        $this->registerArgument(
7✔
54
            'byline',
7✔
55
            'boolean',
7✔
56
            'Show the user’s byline on the video. Defaults to TRUE.',
7✔
57
            false,
7✔
58
            true
7✔
59
        );
7✔
60
        $this->registerArgument(
7✔
61
            'portrait',
7✔
62
            'boolean',
7✔
63
            'Show the user’s portrait on the video. Defaults to TRUE.',
7✔
64
            false,
7✔
65
            true
7✔
66
        );
7✔
67
        $this->registerArgument(
7✔
68
            'color',
7✔
69
            'string',
7✔
70
            'Specify the color of the video controls. Defaults to 00adef. Make sure that you don’t include the #.',
7✔
71
            false,
7✔
72
            '00adef'
7✔
73
        );
7✔
74
        $this->registerArgument(
7✔
75
            'autoplay',
7✔
76
            'boolean',
7✔
77
            'Play the video automatically on load. Defaults to FALSE. Note that this won’t work on some devices.',
7✔
78
            false,
7✔
79
            false
7✔
80
        );
7✔
81
        $this->registerArgument(
7✔
82
            'loop',
7✔
83
            'boolean',
7✔
84
            'Play the video again when it reaches the end. Defaults to FALSE.',
7✔
85
            false,
7✔
86
            false
7✔
87
        );
7✔
88
        $this->registerArgument('api', 'boolean', 'Set to TRUE to enable the Javascript API.', false, false);
7✔
89
        $this->registerArgument(
7✔
90
            'playerId',
7✔
91
            'string',
7✔
92
            'An unique id for the player that will be passed back with all Javascript API responses.'
7✔
93
        );
7✔
94
    }
95

96
    /**
97
     * Render method
98
     *
99
     * @return string
100
     */
101
    public function render()
102
    {
103
        /** @var string $videoId */
104
        $videoId = $this->arguments['videoId'];
×
105
        /** @var int $width */
106
        $width = $this->arguments['width'];
×
107
        /** @var int $height */
108
        $height = $this->arguments['height'];
×
109

110
        $src = static::VIMEO_BASEURL . $videoId . '?';
×
111

112
        /** @var string $color */
113
        $color = $this->arguments['color'];
×
114

115
        $queryParams = [
×
116
            'title='     . (bool) $this->arguments['title'],
×
117
            'byline='    . (bool) $this->arguments['byline'],
×
118
            'portrait='  . (bool) $this->arguments['portrait'],
×
119
            'color='     . str_replace('#', '', $color),
×
120
            'autoplay='  . (bool) $this->arguments['autoplay'],
×
121
            'loop='      . (bool) $this->arguments['loop'],
×
122
            'api='       . (bool) $this->arguments['api'],
×
123
            'player_id=' . $this->arguments['playerId'],
×
124
        ];
×
125

126
        $src .= implode('&', $queryParams);
×
127

128
        $this->tag->forceClosingTag(true);
×
129
        $this->tag->addAttribute('src', $src);
×
130
        $this->tag->addAttribute('width', (string) $width);
×
131
        $this->tag->addAttribute('height', (string) $height);
×
132
        $this->tag->addAttribute('frameborder', '0');
×
133
        $this->tag->addAttribute('webkitAllowFullScreen', 'webkitAllowFullScreen');
×
134
        $this->tag->addAttribute('mozAllowFullScreen', 'mozAllowFullScreen');
×
135
        $this->tag->addAttribute('allowFullScreen', 'allowFullScreen');
×
136

137
        return $this->tag->render();
×
138
    }
139
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc