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 / BackgroundImage.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
BackgroundImage.php
82 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 Kubio\Core\StyleManager\Props\BackgroundImage as BackgroundImageProp;
10 use Kubio\Core\StyleManager\Props\Background;
11
12 class BackgroundImage extends ElementBase {
13 function __construct( $value ) {
14 parent::__construct( $value, BackgroundDefaults::getDefaultImage() );
15 }
16
17 function wrapperComputedStyle() {
18
19 if ( $this->useParallaxScript() ) {
20 $url = $this->get( '0.source.url' );
21 $style['backgroundImage'] = "url(\"$url\")";
22 } else {
23 $image = $this->getMergedValue();
24 $image = $image[0];
25 $bg = new Background( 'background' );
26 $bgImage = new BackgroundImageProp( $image, $bg->config( 'default' ) );
27 $style = $bgImage->toStyle();
28 }
29 if ( $this->useFeaturedImage() ) {
30 $url = get_the_post_thumbnail_url( null, 'full' );
31 $style['backgroundImage'] = "url(\"$url\")";
32 }
33
34 return $style;
35 }
36
37 function useParallaxScript() {
38 return $this->get( '0.useParallax' );
39 }
40 function useFeaturedImage() {
41 return $this->get( '0.useFeaturedImage' );
42 }
43 function useBackgroundLayer() {
44 return $this->get( '0.forceBackgroundLayer' );
45 }
46 function getClasses() {
47 $classes = array( 'background-layer' );
48 if ( $this->useParallaxScript() ) {
49 $classes[] = 'paraxify';
50 }
51 if ( $this->useBackgroundLayer() ) {
52 $classes[] = 'forceBackgroundLayer';
53 }
54
55 return $classes;
56 }
57
58 function __toString() {
59 $classes = $this->getClasses();
60
61 $scriptData = Utils::useJSComponentProps(
62 'parallax',
63 array(
64 'enabled' => $this->useParallaxScript(),
65 'test' => 'temp',
66 )
67 );
68
69 return new Element(
70 Element::DIV,
71 array_merge(
72 $scriptData,
73 array(
74 'style' => $this->wrapperComputedStyle(),
75 'className' => $classes,
76 )
77 )
78 ) . '';
79
80 }
81 }
82