PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.2.0
Kubio AI Page Builder v2.2.0
2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / src / Core / Background / BackgroundVideo.php
kubio / lib / src / Core / Background Last commit date
Background.php 4 years ago BackgroundDefaults.php 2 years ago BackgroundImage.php 4 years ago BackgroundOverlay.php 4 years ago BackgroundSlideshow.php 4 years ago BackgroundVideo.php 3 years ago
BackgroundVideo.php
71 lines
1 <?php
2
3 namespace Kubio\Core\Background;
4
5 use Kubio\Config;
6 use Kubio\Core\Element;
7 use Kubio\Core\ElementBase;
8 use Kubio\Core\Utils;
9 use function floatval;
10
11 class BackgroundVideo extends ElementBase {
12 const YOUTUBE_MIME = 'video/x-youtube';
13 function __construct( $value ) {
14 parent::__construct( $value, BackgroundDefaults::getDefaultVideo() );
15 }
16
17 function wrapperComputedStyle() {
18 $url = $this->get( 'poster.url' );
19 $style = array(
20 'backgroundImage' => "url(\"$url\")",
21 );
22 return $style;
23 }
24
25 function __toString() {
26 $poster = $this->get( 'poster.url' );
27 $videoType = $this->get( 'type' );
28 $position = $this->get( 'position' );
29 $internalVideoMime = $this->get( 'internal.mimeType' );
30
31 // fallback on the 'mime' path
32 if ( empty( $internalVideoMimeType ) ) {
33 $internalVideoMime = $this->get( 'internal.mime' );
34 }
35
36 $url = $this->get( "{$videoType}.url" );
37 $positionX = floatval( $position['x'] );
38 $positionY = floatval( $position['y'] );
39
40 $mimeType = $videoType === 'internal' ? $internalVideoMime : self::YOUTUBE_MIME;
41
42 $id = 'background-video';
43
44 $scriptData = Utils::useJSComponentProps(
45 'video-background',
46 array(
47 'positionX' => $positionX,
48 'positionY' => $positionY,
49 'mimeType' => $mimeType,
50 'poster' => $poster,
51 'video' => $url,
52 )
53 );
54
55 $props = array_merge(
56 array(
57 'id' => $id,
58 'style' => $this->wrapperComputedStyle(),
59 'className' => array(
60 'cp-video-bg',
61 'background-layer',
62 'kubio-video-background',
63 ),
64 ),
65 $scriptData
66 );
67
68 return new Element( Element::DIV, $props ) . '';
69 }
70 }
71