null, // Default value is null 'size' => 'thumbnail', // Default image size 'link' => 'no', // Default link value is 'no' 'new_window' => 'no', // Default new window value is 'no' ), $atts, 'aio_page_featured_image' ); if (empty($atts['id'])) { // If 'id' attribute is not provided, use the current page ID $page_id = get_the_ID(); } else { // Use the specified page ID $page_id = absint($atts['id']); } // Validate the size attribute to use only allowed sizes (thumbnail, medium, large) $allowed_sizes = array('thumbnail', 'medium', 'large'); $atts['size'] = in_array($atts['size'], $allowed_sizes) ? $atts['size'] : 'thumbnail'; // Get the featured image ID for the page $thumbnail_id = get_post_thumbnail_id($page_id); if ($thumbnail_id) { // Get the image HTML using wp_get_attachment_image() $image_html = wp_get_attachment_image($thumbnail_id, $atts['size'], false, array('alt' => esc_attr(get_the_title($page_id)))); // Check if link attribute is set to yes if ($atts['link'] === 'yes') { $target = $atts['new_window'] === 'yes' ? ' target="_blank"' : ''; return '' . $image_html . ''; } else { return $image_html; } } else { return ''; // No featured image found } } add_shortcode('aio_page_featured_image', 'aiosc_page_featured_image_shortcode');