1, 'tablet' => 1, 'mobile' => 1, ); } /** * No gap on the main slider. * * @return int */ protected function default_space_between() { return 0; } /** * Slide and fade suit a gallery. * * @return array */ protected function get_effect_options() { return array( 'slide' => esc_html__( 'Slide', 'advance-elementor-slider' ), 'fade' => esc_html__( 'Fade', 'advance-elementor-slider' ), ); } /** * Register controls. */ protected function register_controls() { $this->register_gallery_section(); $this->register_thumbs_section(); $this->register_slider_options_section(); $this->register_navigation_section(); $this->register_main_style_section(); $this->register_thumbs_style_section(); $this->register_caption_style_section(); $this->register_arrows_style_section(); $this->register_pagination_style_section(); } /** * Gallery source. */ private function register_gallery_section() { $this->start_controls_section( 'aels_section_gallery', array( 'label' => esc_html__( 'Gallery', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'gallery', array( 'label' => esc_html__( 'Images', 'advance-elementor-slider' ), 'type' => Controls_Manager::GALLERY, 'dynamic' => array( 'active' => true ), 'default' => array(), ) ); $this->add_group_control( Group_Control_Image_Size::get_type(), array( 'name' => 'main_image', 'default' => 'large', ) ); $this->add_control( 'show_caption', array( 'label' => esc_html__( 'Show Caption', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => '', 'separator' => 'before', ) ); $this->add_control( 'caption_source', array( 'label' => esc_html__( 'Caption Source', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT, 'default' => 'caption', 'options' => array( 'caption' => esc_html__( 'Attachment Caption', 'advance-elementor-slider' ), 'title' => esc_html__( 'Attachment Title', 'advance-elementor-slider' ), 'description' => esc_html__( 'Attachment Description', 'advance-elementor-slider' ), ), 'condition' => array( 'show_caption' => 'yes' ), ) ); $this->end_controls_section(); } /** * Thumbnail strip options. */ private function register_thumbs_section() { $this->start_controls_section( 'aels_section_thumbs', array( 'label' => esc_html__( 'Thumbnails', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'show_thumbs', array( 'label' => esc_html__( 'Show Thumbnail Strip', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_group_control( Group_Control_Image_Size::get_type(), array( 'name' => 'thumb_image', 'default' => 'thumbnail', 'condition' => array( 'show_thumbs' => 'yes' ), ) ); $this->add_responsive_control( 'thumbs_per_view', array( 'label' => esc_html__( 'Thumbnails Per View', 'advance-elementor-slider' ), 'type' => Controls_Manager::NUMBER, 'min' => 2, 'max' => 12, 'default' => 5, 'tablet_default' => 4, 'mobile_default' => 3, 'condition' => array( 'show_thumbs' => 'yes' ), ) ); $this->add_responsive_control( 'thumbs_space', array( 'label' => esc_html__( 'Thumbnail Gap (px)', 'advance-elementor-slider' ), 'type' => Controls_Manager::NUMBER, 'min' => 0, 'max' => 60, 'default' => 10, 'condition' => array( 'show_thumbs' => 'yes' ), ) ); $this->end_controls_section(); } /** * Main image styling. */ private function register_main_style_section() { $this->start_controls_section( 'aels_style_main', array( 'label' => esc_html__( 'Main Image', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_responsive_control( 'main_height', array( 'label' => esc_html__( 'Height', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px', 'vh' ), 'range' => array( 'px' => array( 'min' => 150, 'max' => 900, ), 'vh' => array( 'min' => 20, 'max' => 100, ), ), 'default' => array( 'unit' => 'px', 'size' => 480, ), 'selectors' => array( '{{WRAPPER}} .aels-gallery__main-img' => 'height: {{SIZE}}{{UNIT}};', ), ) ); $this->add_control( 'main_fit', array( 'label' => esc_html__( 'Image Fit', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT, 'default' => 'cover', 'options' => array( 'cover' => esc_html__( 'Cover', 'advance-elementor-slider' ), 'contain' => esc_html__( 'Contain', 'advance-elementor-slider' ), 'fill' => esc_html__( 'Fill', 'advance-elementor-slider' ), ), 'selectors' => array( '{{WRAPPER}} .aels-gallery__main-img' => 'object-fit: {{VALUE}};', ), ) ); $this->add_control( 'main_radius', array( 'label' => esc_html__( 'Border Radius', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 10, 'right' => 10, 'bottom' => 10, 'left' => 10, 'unit' => 'px', 'isLinked' => true, ), 'selectors' => array( '{{WRAPPER}} .aels-swiper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->end_controls_section(); } /** * Thumbnail strip styling. */ private function register_thumbs_style_section() { $this->start_controls_section( 'aels_style_thumbs', array( 'label' => esc_html__( 'Thumbnail Strip', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => array( 'show_thumbs' => 'yes' ), ) ); $this->add_responsive_control( 'thumbs_top_gap', array( 'label' => esc_html__( 'Distance From Main Image', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px' ), 'range' => array( 'px' => array( 'min' => 0, 'max' => 80, ), ), 'default' => array( 'unit' => 'px', 'size' => 12, ), 'selectors' => array( '{{WRAPPER}} .aels-thumbs' => 'margin-top: {{SIZE}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'thumb_height', array( 'label' => esc_html__( 'Thumbnail Height', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px' ), 'range' => array( 'px' => array( 'min' => 40, 'max' => 240, ), ), 'default' => array( 'unit' => 'px', 'size' => 90, ), 'selectors' => array( '{{WRAPPER}} .aels-thumbs__img' => 'height: {{SIZE}}{{UNIT}};', ), ) ); $this->add_control( 'thumb_radius', array( 'label' => esc_html__( 'Border Radius', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 6, 'right' => 6, 'bottom' => 6, 'left' => 6, 'unit' => 'px', 'isLinked' => true, ), 'selectors' => array( '{{WRAPPER}} .aels-thumbs__img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_control( 'thumb_opacity', array( 'label' => esc_html__( 'Inactive Opacity', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0.1, 'max' => 1, 'step' => 0.05, ), ), 'default' => array( 'size' => 0.5 ), 'selectors' => array( '{{WRAPPER}} .aels-thumbs .swiper-slide .aels-thumbs__img' => 'opacity: {{SIZE}};', ), ) ); $this->add_group_control( Group_Control_Border::get_type(), array( 'name' => 'thumb_active_border', 'selector' => '{{WRAPPER}} .aels-thumbs .swiper-slide-thumb-active .aels-thumbs__img', 'fields_options' => array( 'border' => array( 'default' => 'solid' ), 'width' => array( 'default' => array( 'top' => 2, 'right' => 2, 'bottom' => 2, 'left' => 2, 'isLinked' => true, ), ), 'color' => array( 'default' => '#2563eb' ), ), ) ); $this->end_controls_section(); } /** * Caption styling. */ private function register_caption_style_section() { $this->start_controls_section( 'aels_style_caption', array( 'label' => esc_html__( 'Caption', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => array( 'show_caption' => 'yes' ), ) ); $this->add_control( 'caption_color', array( 'label' => esc_html__( 'Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => array( '{{WRAPPER}} .aels-gallery__caption' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'caption_bg', array( 'label' => esc_html__( 'Background', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => 'rgba(0, 0, 0, 0.55)', 'selectors' => array( '{{WRAPPER}} .aels-gallery__caption' => 'background-color: {{VALUE}};', ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'caption_typography', 'selector' => '{{WRAPPER}} .aels-gallery__caption', ) ); $this->add_responsive_control( 'caption_padding', array( 'label' => esc_html__( 'Padding', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em' ), 'default' => array( 'top' => 12, 'right' => 18, 'bottom' => 12, 'left' => 18, 'unit' => 'px', 'isLinked' => false, ), 'selectors' => array( '{{WRAPPER}} .aels-gallery__caption' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->end_controls_section(); } /** * Render the widget. */ protected function render() { $settings = $this->get_settings_for_display(); if ( empty( $settings['gallery'] ) || ! is_array( $settings['gallery'] ) ) { $this->render_empty_notice( esc_html__( 'Choose some images for the gallery.', 'advance-elementor-slider' ) ); return; } $show_thumbs = $this->is_on( $settings, 'show_thumbs' ); $extra_settings = array( 'thumbs' => $show_thumbs, 'thumbsPerView' => $this->get_responsive_number( $settings, 'thumbs_per_view', 5 ), 'thumbsSpace' => $this->get_responsive_number( $settings, 'thumbs_space', 10 ), ); $this->render_slider_start( $settings, array( 'aels-slider--gallery' ), $extra_settings ); foreach ( $settings['gallery'] as $image ) { $this->render_main_slide( $image, $settings ); } // Close swiper-wrapper and swiper, then print thumbs before the navigation. ?>