get_the_post_thumbnail_url example


        $inner_container_start = '/<div\b[^>]+wp-block-cover__inner-container[\s|"][^>]*>/U';
        if ( 1 === preg_match( $inner_container_start$content$matches, PREG_OFFSET_CAPTURE ) ) {
            $offset  = $matches[0][1];
            $content = substr( $content, 0, $offset ) . $image . substr( $content$offset );
        }
    } else {
        if ( in_the_loop() ) {
            update_post_thumbnail_cache();
        }
        $current_featured_image = get_the_post_thumbnail_url();
        if ( ! $current_featured_image ) {
            return $content;
        }

        $processor = new WP_HTML_Tag_Processor( $content );
        $processor->next_tag();

        $styles         = $processor->get_attribute( 'style' );
        $merged_styles  = ! empty( $styles ) ? $styles . ';' : '';
        $merged_styles .= 'background-image:url(' . esc_url( $current_featured_image ) . ');';

        
/** * Displays the post thumbnail URL. * * @since 4.4.0 * * @param string|int[] $size Optional. Image size to use. Accepts any valid image size, * or an array of width and height values in pixels (in that order). * Default 'post-thumbnail'. */
function the_post_thumbnail_url( $size = 'post-thumbnail' ) {
    $url = get_the_post_thumbnail_url( null, $size );

    if ( $url ) {
        echo esc_url( $url );
    }
}

/** * Returns the post thumbnail caption. * * @since 4.6.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. * @return string Post thumbnail caption. */
Home | Imprint | This part of the site doesn't use cookies.