ID, 'page-thumbnail' ); $page_thumbnail_size = starlight_has_large_featured_image( $post->ID ); if ( 'large' === $page_thumbnail_size ) { return; } if ( ! is_single() ) { echo ''; } // Print the HTML of the image echo ""; // use the standard featured image function the_post_thumbnail( $size, $attr ); echo ""; if ( ! is_single() ) { echo ''; } } /** * We are using very wide image size. If they don't have such do not show it, instead * print the featured image in the entry's post content. We will have default background * set from the CSS of the theme. */ function starlight_has_large_featured_image( $post_ID ) { // Grab the width of the page thumbnail. $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post_ID ), "featured-large" ); $image_width = $image_data[1]; // If the image they've provided isn't big enough use the smaller one in the content. if ( 1920 != $image_width ) { return 'normal'; } return 'large'; } /** * Prints header image on top of the page. If on single post with thumbnail that * is big enough then print that. Else default back to the header image. * * @param [string] $location 'before-menu' or 'after-menu' * @todo optimize the image file loading * @todo make sure that $post exists before using it */ function starlight_header_image( $location ) { global $post; $has_image = has_header_image(); if ( function_exists( 'is_woocommerce' ) ) { if ( is_woocommerce() ) { return; } } // Don't do this in WooCommerce if ( true === $has_image ) { $header_image_url = get_header_image(); } // If the header image is not set get out of here :) if ( is_singular() && has_post_thumbnail( $post->ID ) ) { $page_thumbnail_large = get_the_post_thumbnail_url( $post->ID, 'featured-large' ); $page_thumbnail_size = starlight_has_large_featured_image( $post->ID ); if ( 'large' === $page_thumbnail_size ) { $header_image_url = $page_thumbnail_large; } } if ( ! empty( $post ) ) { $get_post = get_post( get_post_thumbnail_id( $post->ID ) ); if ( is_object( $get_post ) ) { $header_image_caption = $get_post->post_excerpt; } } $header_image_title = get_bloginfo( 'title' ); // This is the final part - just print it on the page. $starlight_theme_mod = get_theme_mod( 'starlight_header_image_position' ); if ( empty( $starlight_theme_mod ) ) { $position = 'after-menu'; }else{ $position = $starlight_theme_mod; } if ( $has_image && $location === esc_attr ( $position ) ) { ?>