PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.5
Elementor Website Builder – more than just a page builder v4.1.5
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 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / controls / image-dimensions.php

image-dimensions.php in Elementor Website Builder – more than just a page builder 4.1.5, at includes/controls/image-dimensions.php

125 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor image dimensions control.
10 *
11 * A base control for creating image dimension control. Displays image width
12 * input, image height input and an apply button.
13 *
14 * @since 1.0.0
15 */
16 class Control_Image_Dimensions extends Control_Base_Multiple {
17
18 /**
19 * Get image dimensions control type.
20 *
21 * Retrieve the control type, in this case `image_dimensions`.
22 *
23 * @since 1.0.0
24 * @access public
25 *
26 * @return string Control type.
27 */
28 public function get_type() {
29 return 'image_dimensions';
30 }
31
32 /**
33 * Get image dimensions control default values.
34 *
35 * Retrieve the default value of the image dimensions control. Used to return the
36 * default values while initializing the image dimensions control.
37 *
38 * @since 1.0.0
39 * @access public
40 *
41 * @return array Control default value.
42 */
43 public function get_default_value() {
44 return [
45 'width' => '',
46 'height' => '',
47 ];
48 }
49
50 /**
51 * Get image dimensions control default settings.
52 *
53 * Retrieve the default settings of the image dimensions control. Used to return
54 * the default settings while initializing the image dimensions control.
55 *
56 * @since 1.0.0
57 * @access protected
58 *
59 * @return array Control default settings.
60 */
61 protected function get_default_settings() {
62 return [
63 'show_label' => false,
64 'label_block' => true,
65 ];
66 }
67
68 /**
69 * Render image dimensions control output in the editor.
70 *
71 * Used to generate the control HTML in the editor using Underscore JS
72 * template. The variables for the class are available using `data` JS
73 * object.
74 *
75 * @since 1.0.0
76 * @access public
77 */
78 public function content_template() {
79 if ( ! $this->is_image_editor_supports() ) : ?>
80 <div class="elementor-panel-alert elementor-panel-alert-danger">
81 <?php echo esc_html__( 'The server does not have ImageMagick or GD installed and/or enabled! Any of these libraries are required for WordPress to be able to resize images. Please contact your server administrator to enable this before continuing.', 'elementor' ); ?>
82 </div>
83 <?php
84 return;
85 endif;
86 ?>
87 <# if ( data.description ) { #>
88 <div class="elementor-control-field-description">{{{ data.description }}}</div>
89 <# } #>
90 <div class="elementor-control-field">
91 <label class="elementor-control-title">{{{ data.label }}}</label>
92 <div class="elementor-control-input-wrapper">
93 <div class="elementor-image-dimensions-field elementor-control-unit-2">
94 <input id="<?php $this->print_control_uid( 'width' ); ?>" type="number" data-setting="width" />
95 <label for="<?php $this->print_control_uid( 'width' ); ?>" class="elementor-image-dimensions-field-description"><?php echo esc_html__( 'Width', 'elementor' ); ?></label>
96 </div>
97 <div class="elementor-image-dimensions-separator">x</div>
98 <div class="elementor-image-dimensions-field elementor-control-unit-2">
99 <input id="<?php $this->print_control_uid( 'height' ); ?>" type="number" data-setting="height" />
100 <label for="<?php $this->print_control_uid( 'height' ); ?>" class="elementor-image-dimensions-field-description"><?php echo esc_html__( 'Height', 'elementor' ); ?></label>
101 </div>
102 <button class="elementor-button elementor-image-dimensions-apply-button"><?php echo esc_html__( 'Apply', 'elementor' ); ?></button>
103 </div>
104 </div>
105 <?php
106 }
107
108 /**
109 * Image editor support.
110 *
111 * Used to determine whether the editor supports a given image mime-type.
112 *
113 * @since 2.0.0
114 * @access private
115 *
116 * @return bool Whether the editor supports the given mime-type.
117 */
118 private function is_image_editor_supports() {
119 $arg = [
120 'mime_type' => 'image/jpeg',
121 ];
122 return ( wp_image_editor_supports( $arg ) );
123 }
124 }
125