start_controls_section( 'content_section', [ 'label' => esc_html__('Featured Image Settings', 'easy-elements'), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_responsive_control( 'featured_image_width', [ 'label' => esc_html__('Width', 'easy-elements'), 'type' => Controls_Manager::SLIDER, 'size_units' => ['px', '%'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 1000, ], '%' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .eel-featured-image-inner img' => 'width: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'featured_image_height', [ 'label' => esc_html__('Height', 'easy-elements'), 'type' => Controls_Manager::SLIDER, 'size_units' => ['px', '%'], 'range' => [ 'px' => [ 'min' => 100, 'max' => 1000, ], '%' => [ 'min' => 100, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .eel-featured-image-inner img' => 'height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'border_radius', [ 'label' => esc_html__('Border Radius', 'easy-elements'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '.eel-featured-image-inner' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', ], ] ); // Image Size Control $this->add_control( 'image_size', [ 'label' => esc_html__('Image Size', 'easy-elements'), 'type' => Controls_Manager::SELECT, 'default' => 'full', 'options' => [ 'thumbnail' => esc_html__('Thumbnail', 'easy-elements'), 'medium' => esc_html__('Medium', 'easy-elements'), 'large' => esc_html__('Large', 'easy-elements'), 'full' => esc_html__('Full', 'easy-elements'), ], ] ); // Add show/hide image link control $this->add_control( 'show_image_link', [ 'label' => esc_html__('Show Image Link', 'easy-elements'), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__('Show', 'easy-elements'), 'label_off' => esc_html__('Hide', 'easy-elements'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $image_size = $settings['image_size'] ?? 'full'; $editor_mode = \Elementor\Plugin::instance()->editor->is_edit_mode(); $wrapper_classes = 'eel-featured-image-wrapper' . ( $editor_mode ? ' ' : '' ); $post_id = function_exists('easyel_get_prepared_post_id') ? easyel_get_prepared_post_id() : ( isset($GLOBALS['post']->ID) ? $GLOBALS['post']->ID : 0 ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( !$post_id && isset($_GET['preview_id']) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $post_id = intval(sanitize_text_field(wp_unslash($_GET['preview_id']))); } $image_url = ''; $image_alt = ''; $post_link = ''; if ( $post_id && has_post_thumbnail( $post_id ) ) { $image_url = get_the_post_thumbnail_url( $post_id, $image_size ); $image_alt = get_the_title( $post_id ); $post_link = get_permalink( $post_id ); } ?>