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