PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / trunk
Kubio AI Page Builder vtrunk
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 1 year ago BackgroundDefaults.php 2 years ago BackgroundImage.php 1 year ago BackgroundOverlay.php 1 year ago BackgroundSlideshow.php 1 year ago BackgroundVideo.php 1 year ago
BackgroundVideo.php
72 lines
1 <?php
2
3 namespace Kubio\Core\Background;
4
5 use Kubio\Core\Element;
6 use Kubio\Core\ElementBase;
7 use Kubio\Core\Utils;
8 use function floatval;
9
10 class BackgroundVideo extends ElementBase {
11 const YOUTUBE_MIME = 'video/x-youtube';
12 function __construct( $value ) {
13 parent::__construct( $value, BackgroundDefaults::getDefaultVideo() );
14 }
15
16 function wrapperComputedStyle() {
17 $url = $this->get( 'poster.url' );
18 $url = kubio_wpml_get_translated_media_url( $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 $url = kubio_wpml_get_translated_media_url( $url );
38 $positionX = floatval( $position['x'] );
39 $positionY = floatval( $position['y'] );
40
41 $mimeType = $videoType === 'internal' ? $internalVideoMime : self::YOUTUBE_MIME;
42
43 $id = 'background-video';
44
45 $scriptData = Utils::useJSComponentProps(
46 'video-background',
47 array(
48 'positionX' => $positionX,
49 'positionY' => $positionY,
50 'mimeType' => $mimeType,
51 'poster' => $poster,
52 'video' => $url,
53 )
54 );
55
56 $props = array_merge(
57 array(
58 'id' => $id,
59 'style' => $this->wrapperComputedStyle(),
60 'className' => array(
61 'cp-video-bg',
62 'background-layer',
63 'kubio-video-background',
64 ),
65 ),
66 $scriptData
67 );
68
69 return new Element( Element::DIV, $props ) . '';
70 }
71 }
72