start_controls_section( 'section_image', [ 'label' => __( 'Featured Image', 'admore-widgets-suite' ), ] ); $this->add_control( 'image_size', [ 'label' => __( 'Image Size', 'admore-widgets-suite' ), 'type' => Controls_Manager::SELECT, 'default' => 'full', 'options' => [ 'thumbnail' => __( 'Thumbnail (150×150)', 'admore-widgets-suite' ), 'medium' => __( 'Medium (300×300)', 'admore-widgets-suite' ), 'medium_large' => __( 'Medium Large (768w)', 'admore-widgets-suite' ), 'large' => __( 'Large (1024×1024)', 'admore-widgets-suite' ), 'full' => __( 'Full', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'link_to', [ 'label' => __( 'Link', 'admore-widgets-suite' ), 'type' => Controls_Manager::SELECT, 'default' => 'none', 'options' => [ 'none' => __( 'None', 'admore-widgets-suite' ), 'post' => __( 'Post URL', 'admore-widgets-suite' ), 'file' => __( 'Full Image File', 'admore-widgets-suite' ), 'custom' => __( 'Custom URL', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'custom_link', [ 'label' => __( 'Custom URL', 'admore-widgets-suite' ), 'type' => Controls_Manager::URL, 'condition' => [ 'link_to' => 'custom' ], ] ); $this->add_control( 'link_target', [ 'label' => __( 'Open in New Tab', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'condition' => [ 'link_to!' => 'none' ], ] ); $this->add_responsive_control( 'alignment', [ 'label' => __( 'Alignment', 'admore-widgets-suite' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => __( 'Left', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-left' ], 'center' => [ 'title' => __( 'Center', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-center' ], 'right' => [ 'title' => __( 'Right', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-right' ], ], 'default' => 'center', 'selectors' => [ '{{WRAPPER}} .eppro-fi-wrap' => 'text-align: {{VALUE}};' ], ] ); $this->end_controls_section(); // ── STYLE ───────────────────────────────────────────────────────────── $this->start_controls_section( 'style_image', [ 'label' => __( 'Image', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'image_width', [ 'label' => __( 'Width', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', '%', 'vw' ], 'range' => [ 'px' => [ 'min' => 50, 'max' => 1600 ], '%' => [ 'min' => 5, 'max' => 100 ] ], 'selectors' => [ '{{WRAPPER}} .eppro-fi-img' => 'width: {{SIZE}}{{UNIT}};' ], ] ); $this->add_responsive_control( 'max_height', [ 'label' => __( 'Max Height', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'vh' ], 'range' => [ 'px' => [ 'min' => 50, 'max' => 1200 ] ], 'selectors' => [ '{{WRAPPER}} .eppro-fi-img' => 'max-height: {{SIZE}}{{UNIT}}; object-fit: cover;' ], ] ); $this->add_control( 'border_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .eppro-fi-img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'image_border', 'selector' => '{{WRAPPER}} .eppro-fi-img', ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'image_shadow', 'selector' => '{{WRAPPER}} .eppro-fi-img', ] ); $this->start_controls_tabs( 'image_tabs' ); $this->start_controls_tab( 'image_normal', [ 'label' => __( 'Normal', 'admore-widgets-suite' ) ] ); $this->add_group_control( Group_Control_Css_Filter::get_type(), [ 'name' => 'image_filter', 'selector' => '{{WRAPPER}} .eppro-fi-img', ] ); $this->end_controls_tab(); $this->start_controls_tab( 'image_hover', [ 'label' => __( 'Hover', 'admore-widgets-suite' ) ] ); $this->add_group_control( Group_Control_Css_Filter::get_type(), [ 'name' => 'image_hover_filter', 'selector' => '{{WRAPPER}} .eppro-fi-wrap:hover .eppro-fi-img', ] ); $this->add_control( 'image_hover_scale', [ 'label' => __( 'Scale', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 1, 'max' => 1.5, 'step' => 0.05 ] ], 'default' => [ 'size' => 1.05, 'unit' => 'px' ], 'selectors' => [ '{{WRAPPER}} .eppro-fi-wrap:hover .eppro-fi-img' => 'transform: scale({{SIZE}});' ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); } protected function render(): void { $s = $this->get_settings_for_display(); if ( ! has_post_thumbnail() ) { if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { echo '
' . esc_attr__( 'Placeholder', 'admore-widgets-suite' ) . '
'; } return; } $img_html = get_the_post_thumbnail( null, $s['image_size'], [ 'class' => 'eppro-fi-img' ] ); $link_open = $link_close = ''; $target = ( 'yes' === ( $s['link_target'] ?? '' ) ) ? ' target="_blank"' : ''; switch ( $s['link_to'] ) { case 'post': $link_open = ''; $link_close = ''; break; case 'file': $link_open = ''; $link_close = ''; break; case 'custom': if ( ! empty( $s['custom_link']['url'] ) ) { $nofollow = ! empty( $s['custom_link']['nofollow'] ) ? ' rel="nofollow"' : ''; $link_open = ''; $link_close = ''; } break; } echo wp_kses_post( '
' . $link_open . $img_html . $link_close . '
' ); } }