if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
* Elementor image box widget.
* Elementor widget that displays an image, a headline and a text.
class Widget_Image_Box extends Widget_Base {
* Retrieve image box widget name.
* @return string Widget name.
public function get_name() {
* Retrieve image box widget title.
* @return string Widget title.
public function get_title() {
return esc_html__( 'Image Box', 'elementor' );
* Retrieve image box widget icon.
* @return string Widget icon.
public function get_icon() {
return 'eicon-image-box';
* Retrieve the list of keywords the widget belongs to.
* @return array Widget keywords.
public function get_keywords() {
return [ 'image', 'photo', 'visual', 'box' ];
protected function is_dynamic_content(): bool {
* Get style dependencies.
* Retrieve the list of style dependencies the widget requires.
* @return array Widget style dependencies.
public function get_style_depends(): array {
return [ 'widget-image-box' ];
public function has_widget_inner_wrapper(): bool {
return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
* Register image box widget controls.
* Adds different input fields to allow the user to change and customize the widget settings.
protected function register_controls() {
$this->start_controls_section(
'label' => esc_html__( 'Image Box', 'elementor' ),
'label' => esc_html__( 'Choose Image', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'url' => Utils::get_placeholder_image_src(),
$this->add_group_control(
Group_Control_Image_Size::get_type(),
'name' => 'thumbnail', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `thumbnail_size` and `thumbnail_custom_dimension`.
'label' => esc_html__( 'Title', 'elementor' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'This is the heading', 'elementor' ),
'placeholder' => esc_html__( 'Enter your title', 'elementor' ),
'label' => esc_html__( 'Description', 'elementor' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'elementor' ),
'placeholder' => esc_html__( 'Enter your description', 'elementor' ),
'label' => esc_html__( 'Link', 'elementor' ),
'type' => Controls_Manager::URL,
'label' => esc_html__( 'Title HTML Tag', 'elementor' ),
'type' => Controls_Manager::SELECT,
$this->end_controls_section();
$this->start_controls_section(
'label' => esc_html__( 'Box', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
$this->add_responsive_control(
'label' => esc_html__( 'Image Position', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Left', 'elementor' ),
'icon' => 'eicon-h-align-left',
'title' => esc_html__( 'Top', 'elementor' ),
'icon' => 'eicon-v-align-top',
'title' => esc_html__( 'Right', 'elementor' ),
'icon' => 'eicon-h-align-right',
'prefix_class' => 'elementor-position-',
$this->add_responsive_control(
'content_vertical_alignment',
'label' => esc_html__( 'Vertical Alignment', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Top', 'elementor' ),
'icon' => 'eicon-v-align-top',
'title' => esc_html__( 'Middle', 'elementor' ),
'icon' => 'eicon-v-align-middle',
'title' => esc_html__( 'Bottom', 'elementor' ),
'icon' => 'eicon-v-align-bottom',
'prefix_class' => 'elementor-vertical-align-',
$this->add_responsive_control(
'label' => esc_html__( 'Alignment', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Start', 'elementor' ),
'icon' => 'eicon-text-align-left',
'title' => esc_html__( 'Center', 'elementor' ),
'icon' => 'eicon-text-align-center',
'title' => esc_html__( 'End', 'elementor' ),
'icon' => 'eicon-text-align-right',
'title' => esc_html__( 'Justified', 'elementor' ),
'icon' => 'eicon-text-align-justify',
'classes' => 'elementor-control-start-end',
'selectors_dictionary' => [
'left' => is_rtl() ? 'end' : 'start',
'right' => is_rtl() ? 'start' : 'end',
'{{WRAPPER}} .elementor-image-box-wrapper' => 'text-align: {{VALUE}};',
$this->add_responsive_control(
'label' => esc_html__( 'Image Spacing', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'{{WRAPPER}}.elementor-position-right .elementor-image-box-img' => 'margin-left: {{SIZE}}{{UNIT}};',
'{{WRAPPER}}.elementor-position-left .elementor-image-box-img' => 'margin-right: {{SIZE}}{{UNIT}};',
'{{WRAPPER}}.elementor-position-top .elementor-image-box-img' => 'margin-bottom: {{SIZE}}{{UNIT}};',
'(mobile){{WRAPPER}} .elementor-image-box-img' => 'margin-bottom: {{SIZE}}{{UNIT}};',
$this->add_responsive_control(
'label' => esc_html__( 'Content Spacing', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', 'em', 'rem', 'custom' ],
'{{WRAPPER}} .elementor-image-box-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
$this->end_controls_section();
$this->start_controls_section(
'label' => esc_html__( 'Image', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
$this->add_responsive_control(
'label' => esc_html__( 'Width', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'{{WRAPPER}} .elementor-image-box-wrapper .elementor-image-box-img' => 'width: {{SIZE}}{{UNIT}};',
$this->add_responsive_control(
'label' => esc_html__( 'Height', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ],
'{{WRAPPER}} .elementor-image-box-img img' => 'height: {{SIZE}}{{UNIT}};',
$this->add_responsive_control(
'label' => esc_html__( 'Object Fit', 'elementor' ),
'type' => Controls_Manager::SELECT,
'' => esc_html__( 'Default', 'elementor' ),
'fill' => esc_html__( 'Fill', 'elementor' ),
'cover' => esc_html__( 'Cover', 'elementor' ),
'contain' => esc_html__( 'Contain', 'elementor' ),
'scale-down' => esc_html__( 'Scale Down', 'elementor' ),
'image_height[size]!' => '',
'{{WRAPPER}} .elementor-image-box-img img' => 'object-fit: {{VALUE}};',
$this->add_responsive_control(
'label' => esc_html__( 'Object Position', 'elementor' ),
'type' => Controls_Manager::SELECT,
'center center' => esc_html__( 'Center Center', 'elementor' ),
'center left' => esc_html__( 'Center Left', 'elementor' ),
'center right' => esc_html__( 'Center Right', 'elementor' ),
'top center' => esc_html__( 'Top Center', 'elementor' ),
'top left' => esc_html__( 'Top Left', 'elementor' ),
'top right' => esc_html__( 'Top Right', 'elementor' ),
'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
'bottom right' => esc_html__( 'Bottom Right', 'elementor' ),
'default' => 'center center',
'{{WRAPPER}} .elementor-image-box-img img' => 'object-position: {{VALUE}};',
'image_height[size]!' => '',
'image_object_fit' => [ 'cover', 'contain', 'scale-down' ],
$this->add_group_control(
Group_Control_Border::get_type(),
'name' => 'image_border',
'selector' => '{{WRAPPER}} .elementor-image-box-img img',
$this->add_responsive_control(
'label' => esc_html__( 'Border Radius', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'{{WRAPPER}} .elementor-image-box-img img' => 'border-radius: {{SIZE}}{{UNIT}};',
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
'name' => 'image_box_shadow',
'selector' => '{{WRAPPER}} .elementor-image-box-img img',
'type' => Controls_Manager::DIVIDER,
$this->start_controls_tabs( 'image_effects' );
$this->start_controls_tab(
'label' => esc_html__( 'Normal', 'elementor' ),
$this->add_group_control(
Group_Control_Css_Filter::get_type(),