startControlsSection( 'section_image', [ 'label' => __('Image'), ] ); $this->addControl( 'image', [ 'label' => __('Choose Image'), 'type' => ControlsManager::MEDIA, 'seo' => true, 'dynamic' => [ 'active' => true, ], 'default' => [ 'url' => Utils::getPlaceholderImageSrc(), ], ] ); $this->addResponsiveControl( 'align', [ 'label' => __('Alignment'), 'type' => ControlsManager::CHOOSE, 'options' => [ 'left' => [ 'title' => __('Left'), 'icon' => 'fa fa-align-left', ], 'center' => [ 'title' => __('Center'), 'icon' => 'fa fa-align-center', ], 'right' => [ 'title' => __('Right'), 'icon' => 'fa fa-align-right', ], ], 'selectors' => [ '{{WRAPPER}}' => 'text-align: {{VALUE}};', ], ] ); $this->addControl( 'caption', [ 'label' => __('Custom Caption'), 'label_block' => true, 'type' => ControlsManager::TEXT, 'default' => '', 'placeholder' => __('Enter your image caption'), 'dynamic' => [ 'active' => true, ], ] ); $this->addControl( 'link_to', [ 'label' => __('Link'), 'type' => ControlsManager::SELECT, 'default' => 'none', 'options' => [ 'none' => __('None'), 'file' => __('Media File'), 'custom' => __('Custom URL'), ], ] ); $this->addControl( 'link', [ 'label' => __('Link'), 'type' => ControlsManager::URL, 'dynamic' => [ 'active' => true, ], 'placeholder' => __('https://your-link.com'), 'condition' => [ 'link_to' => 'custom', ], 'show_label' => false, ] ); $this->addControl( 'open_lightbox', [ 'label' => __('Lightbox'), 'type' => ControlsManager::SELECT, 'default' => 'default', 'options' => [ 'default' => __('Default'), 'yes' => __('Yes'), 'no' => __('No'), ], 'condition' => [ 'link_to' => 'file', ], ] ); $this->addControl( 'view', [ 'label' => __('View'), 'type' => ControlsManager::HIDDEN, 'default' => 'traditional', ] ); $this->endControlsSection(); $this->startControlsSection( 'section_style_image', [ 'label' => __('Image'), 'tab' => ControlsManager::TAB_STYLE, ] ); $this->addResponsiveControl( 'width', [ 'label' => __('Width'), 'type' => ControlsManager::SLIDER, 'default' => [ 'unit' => '%', ], 'tablet_default' => [ 'unit' => '%', ], 'mobile_default' => [ 'unit' => '%', ], 'size_units' => ['%', 'px', 'vw'], 'range' => [ '%' => [ 'min' => 1, 'max' => 100, ], 'px' => [ 'min' => 1, 'max' => 1000, ], 'vw' => [ 'min' => 1, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-image img' => 'width: {{SIZE}}{{UNIT}};', ], ] ); $this->addResponsiveControl( 'space', [ 'label' => __('Max Width'), 'type' => ControlsManager::SLIDER, 'default' => [ 'unit' => '%', ], 'tablet_default' => [ 'unit' => '%', ], 'mobile_default' => [ 'unit' => '%', ], 'size_units' => ['%', 'px', 'vw'], 'range' => [ '%' => [ 'min' => 1, 'max' => 100, ], 'px' => [ 'min' => 1, 'max' => 1000, ], 'vw' => [ 'min' => 1, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-image img' => 'max-width: {{SIZE}}{{UNIT}};', ], ] ); $this->addResponsiveControl( 'height', [ 'label' => __('Height'), 'type' => ControlsManager::SLIDER, 'default' => [ 'unit' => 'px', ], 'tablet_default' => [ 'unit' => 'px', ], 'mobile_default' => [ 'unit' => 'px', ], 'size_units' => ['px', 'vh'], 'range' => [ 'px' => [ 'min' => 1, 'max' => 1000, ], 'vh' => [ 'min' => 1, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-image img' => 'height: {{SIZE}}{{UNIT}};', ], ] ); $this->addResponsiveControl( 'object-fit', [ 'label' => __('Object Fit'), 'type' => ControlsManager::SELECT, 'condition' => [ 'height[size]!' => '', ], 'options' => [ '' => __('Default'), 'fill' => _x('Fill', 'Background Control'), 'cover' => _x('Cover', 'Background Control'), 'contain' => _x('Contain', 'Background Control'), ], 'default' => '', 'selectors' => [ '{{WRAPPER}} .elementor-image img' => 'object-fit: {{VALUE}};', ], ] ); $this->addResponsiveControl( 'object_position', [ 'label' => __('Position'), 'type' => ControlsManager::SELECT, 'condition' => [ 'height[size]!' => '', ], 'options' => [ '' => __('Default'), 'top left' => _x('Top Left', 'Background Control'), 'top center' => _x('Top Center', 'Background Control'), 'top right' => _x('Top Right', 'Background Control'), 'center left' => _x('Center Left', 'Background Control'), 'center center' => _x('Center Center', 'Background Control'), 'center right' => _x('Center Right', 'Background Control'), 'bottom left' => _x('Bottom Left', 'Background Control'), 'bottom center' => _x('Bottom Center', 'Background Control'), 'bottom right' => _x('Bottom Right', 'Background Control'), ], 'default' => '', 'selectors' => [ '{{WRAPPER}} .elementor-image img' => 'object-position: {{VALUE}};', ], ] ); $this->addControl( 'separator_panel_style', [ 'type' => ControlsManager::DIVIDER, 'style' => 'thick', ] ); $this->startControlsTabs('image_effects'); $this->startControlsTab( 'normal', [ 'label' => __('Normal'), ] ); $this->addControl( 'opacity', [ 'label' => __('Opacity'), 'type' => ControlsManager::SLIDER, 'range' => [ 'px' => [ 'max' => 1, 'min' => 0.10, 'step' => 0.01, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-image img' => 'opacity: {{SIZE}};', ], ] ); $this->addGroupControl( GroupControlCssFilter::getType(), [ 'name' => 'css_filters', 'selector' => '{{WRAPPER}} .elementor-image img', ] ); $this->endControlsTab(); $this->startControlsTab( 'hover', [ 'label' => __('Hover'), ] ); $this->addControl( 'opacity_hover', [ 'label' => __('Opacity'), 'type' => ControlsManager::SLIDER, 'range' => [ 'px' => [ 'max' => 1, 'min' => 0.10, 'step' => 0.01, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-image:hover img' => 'opacity: {{SIZE}};', ], ] ); $this->addGroupControl( GroupControlCssFilter::getType(), [ 'name' => 'css_filters_hover', 'selector' => '{{WRAPPER}} .elementor-image:hover img', ] ); $this->addControl( 'background_hover_transition', [ 'label' => __('Transition Duration'), 'type' => ControlsManager::SLIDER, 'range' => [ 'px' => [ 'max' => 3, 'step' => 0.1, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-image img' => 'transition-duration: {{SIZE}}s', ], ] ); $this->addControl( 'hover_animation', [ 'label' => __('Hover Animation'), 'type' => ControlsManager::HOVER_ANIMATION, ] ); $this->endControlsTab(); $this->endControlsTabs(); $this->addGroupControl( GroupControlBorder::getType(), [ 'name' => 'image_border', 'selector' => '{{WRAPPER}} .elementor-image img', 'separator' => 'before', ] ); $this->addResponsiveControl( 'image_border_radius', [ 'label' => __('Border Radius'), 'type' => ControlsManager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .elementor-image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->addGroupControl( GroupControlBoxShadow::getType(), [ 'name' => 'image_box_shadow', 'exclude' => [ 'box_shadow_position', ], 'selector' => '{{WRAPPER}} .elementor-image img', ] ); $this->endControlsSection(); $this->startControlsSection( 'section_style_caption', [ 'label' => __('Caption'), 'tab' => ControlsManager::TAB_STYLE, 'condition' => [ 'caption!' => '', ], ] ); $this->addControl( 'caption_align', [ 'label' => __('Alignment'), 'type' => ControlsManager::CHOOSE, 'options' => [ 'left' => [ 'title' => __('Left'), 'icon' => 'fa fa-align-left', ], 'center' => [ 'title' => __('Center'), 'icon' => 'fa fa-align-center', ], 'right' => [ 'title' => __('Right'), 'icon' => 'fa fa-align-right', ], 'justify' => [ 'title' => __('Justified'), 'icon' => 'fa fa-align-justify', ], ], 'default' => '', 'selectors' => [ '{{WRAPPER}} .widget-image-caption' => 'text-align: {{VALUE}};', ], ] ); $this->addControl( 'text_color', [ 'label' => __('Text Color'), 'type' => ControlsManager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .widget-image-caption' => 'color: {{VALUE}};', ], 'scheme' => [ 'type' => SchemeColor::getType(), 'value' => SchemeColor::COLOR_3, ], ] ); $this->addControl( 'caption_background_color', [ 'label' => __('Background Color'), 'type' => ControlsManager::COLOR, 'selectors' => [ '{{WRAPPER}} .widget-image-caption' => 'background-color: {{VALUE}};', ], ] ); $this->addGroupControl( GroupControlTypography::getType(), [ 'name' => 'caption_typography', 'selector' => '{{WRAPPER}} .widget-image-caption', 'scheme' => SchemeTypography::TYPOGRAPHY_3, ] ); $this->addGroupControl( GroupControlTextShadow::getType(), [ 'name' => 'caption_text_shadow', 'selector' => '{{WRAPPER}} .widget-image-caption', ] ); $this->addResponsiveControl( 'caption_space', [ 'label' => __('Spacing'), 'type' => ControlsManager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .widget-image-caption' => 'margin-top: {{SIZE}}{{UNIT}};', ], ] ); $this->endControlsSection(); } /** * Render image widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.0.0 * @access protected */ protected function render() { $settings = $this->getSettingsForDisplay(); if (empty($settings['image']['url'])) { return; } $has_caption = !empty($settings['caption']); $link = $this->getLinkUrl($settings); if ($link) { $this->addRenderAttribute('link', [ 'href' => $link['url'], 'data-elementor-open-lightbox' => $settings['open_lightbox'], ]); if (Plugin::$instance->editor->isEditMode()) { $this->addRenderAttribute('link', [ 'class' => 'elementor-clickable', ]); } if (!empty($link['is_external'])) { $this->addRenderAttribute('link', 'target', '_blank'); } if (!empty($link['nofollow'])) { $this->addRenderAttribute('link', 'rel', 'nofollow'); } }?>