PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-beta1
Elementor Website Builder – more than just a page builder v3.28.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 All 457 releases
← All changes | modules/atomic-widgets/props-resolver/transformers/styles/background-image-overlay-transformer.php +32 -13 4.1.0-dev3 → 3.28.0-beta1 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2
3 3 namespace Elementor\Modules\AtomicWidgets\PropsResolver\Transformers\Styles;
4 4
5 -use Elementor\Modules\AtomicWidgets\PropsResolver\Props_Resolver_Context;
6 5 use Elementor\Modules\AtomicWidgets\PropsResolver\Transformer_Base;
7 6
8 7 if ( ! defined( 'ABSPATH' ) ) {
9 8 exit; // Exit if accessed directly.
@@ -9,15 +8,11 @@
9 8 exit; // Exit if accessed directly.
10 9 }
11 10
12 11 class Background_Image_Overlay_Transformer extends Transformer_Base {
13 - const DEFAULT_IMAGE = 'none';
14 - const DEFAULT_REPEAT = 'repeat';
15 - const DEFAULT_ATTACHMENT = 'scroll';
16 - const DEFAULT_SIZE = 'auto auto';
17 12 const DEFAULT_POSITION = '0% 0%';
18 13
19 - public function transform( $value, Props_Resolver_Context $context ) {
14 + public function transform( $value, $key ) {
20 15 if ( ! isset( $value['image'] ) ) {
21 16 return '';
22 17 }
23 18
@@ -22,13 +17,37 @@
22 17 }
23 18
24 19 $image_url = $value['image']['src'];
25 20
26 - return [
27 - 'src' => "url(\"$image_url\")",
28 - 'repeat' => $value['repeat'] ?? null,
29 - 'attachment' => $value['attachment'] ?? null,
30 - 'size' => $value['size'] ?? null,
31 - 'position' => $value['position'] ?? null,
32 - ];
21 + $background_style = "url(\" $image_url \")";
22 +
23 + if ( ! empty( $value['repeat'] ) ) {
24 + $background_style .= ' ' . $value['repeat'];
25 + }
26 +
27 + if ( ! empty( $value['attachment'] ) ) {
28 + $background_style .= ' ' . $value['attachment'];
29 + }
30 +
31 + $position_and_size_style = $this->get_position_and_size_style( $value );
32 +
33 + if ( ! empty( $position_and_size_style ) ) {
34 + $background_style .= ' ' . $position_and_size_style;
35 + }
36 +
37 + return $background_style;
38 + }
39 +
40 + private function get_position_and_size_style( array $value ): string {
41 + if ( ! isset( $value['size'] ) && ! isset( $value['position'] ) ) {
42 + return '';
43 + }
44 +
45 + if ( ! isset( $value['size'] ) ) {
46 + return $value['position'];
47 + }
48 +
49 + $position = $value['position'] ?? self::DEFAULT_POSITION;
50 +
51 + return $position . ' / ' . $value['size'];
33 52 }
34 53 }