has_post_thumbnail example

foreach ( $recent_posts as $post ) {
        $post_link = esc_url( get_permalink( $post ) );
        $title     = get_the_title( $post );

        if ( ! $title ) {
            $title = __( '(no title)' );
        }

        $list_items_markup .= '<li>';

        if ( $attributes['displayFeaturedImage'] && has_post_thumbnail( $post ) ) {
            $image_style = '';
            if ( isset( $attributes['featuredImageSizeWidth'] ) ) {
                $image_style .= sprintf( 'max-width:%spx;', $attributes['featuredImageSizeWidth'] );
            }
            if ( isset( $attributes['featuredImageSizeHeight'] ) ) {
                $image_style .= sprintf( 'max-height:%spx;', $attributes['featuredImageSizeHeight'] );
            }

            $image_classes = 'wp-block-latest-posts__featured-image';
            if ( isset( $attributes['featuredImageAlign'] ) ) {
                $image_classes .= ' align' . $attributes['featuredImageAlign'];
            }

function twenty_twenty_one_can_show_post_thumbnail() {
    /** * Filters whether post thumbnail can be displayed. * * @since Twenty Twenty-One 1.0 * * @param bool $show_post_thumbnail Whether to show post thumbnail. */
    return apply_filters(
        'twenty_twenty_one_can_show_post_thumbnail',
        ! post_password_required() && ! is_attachment() && has_post_thumbnail()
    );
}

/** * Returns the size for avatars used in the theme. * * @since Twenty Twenty-One 1.0 * * @return int */
function twenty_twenty_one_get_avatar_size() {
    


?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php if ( ! is_front_page() ) : ?> <header class="entry-header alignwide"> <?php get_template_part( 'template-parts/header/entry-header' ); ?> <?php twenty_twenty_one_post_thumbnail(); ?> </header><!-- .entry-header --> <?php elseif ( has_post_thumbnail() ) : ?> <header class="entry-header alignwide"> <?php twenty_twenty_one_post_thumbnail(); ?> </header><!-- .entry-header --> <?php endif; ?> <div class="entry-content"> <?php         the_content();

        wp_link_pages(
            array(
                

function get_oembed_response_data_rich( $data$post$width$height ) {
    $data['width']  = absint( $width );
    $data['height'] = absint( $height );
    $data['type']   = 'rich';
    $data['html']   = get_post_embed_html( $width$height$post );

    // Add post thumbnail to response if available.     $thumbnail_id = false;

    if ( has_post_thumbnail( $post->ID ) ) {
        $thumbnail_id = get_post_thumbnail_id( $post->ID );
    }

    if ( 'attachment' === get_post_type( $post ) ) {
        if ( wp_attachment_is_image( $post ) ) {
            $thumbnail_id = $post->ID;
        } elseif ( wp_attachment_is( 'video', $post ) ) {
            $thumbnail_id = get_post_thumbnail_id( $post );
            $data['type'] = 'video';
        }
    }

    

?> <div <?php post_class( 'wp-embed' ); ?>> <?php         $thumbnail_id = 0;

        if ( has_post_thumbnail() ) {
            $thumbnail_id = get_post_thumbnail_id();
        }

        if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) {
            $thumbnail_id = get_the_ID();
        }

        /** * Filters the thumbnail image ID for use in the embed template. * * @since 4.9.0 * * @param int|false $thumbnail_id Attachment ID, or false if there is none. */
$post_password_required = post_password_required( $post->ID );

    // Post requires password.     if ( $post_password_required ) {
        $classes[] = 'post-password-required';
    } elseif ( ! empty( $post->post_password ) ) {
        $classes[] = 'post-password-protected';
    }

    // Post thumbnails.     if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) {
        $classes[] = 'has-post-thumbnail';
    }

    // Sticky for Sticky Posts.     if ( is_sticky( $post->ID ) ) {
        if ( is_home() && ! is_paged() ) {
            $classes[] = 'sticky';
        } elseif ( is_admin() ) {
            $classes[] = 'status-sticky';
        }
    }

    

    public function column_title( $post ) {
        list( $mime ) = explode( '/', $post->post_mime_type );

        $attachment_id = $post->ID;

        if ( has_post_thumbnail( $post ) ) {
            $thumbnail_id = get_post_thumbnail_id( $post );

            if ( ! empty( $thumbnail_id ) ) {
                $attachment_id = $thumbnail_id;
            }
        }

        $title      = _draft_or_post_title();
        $thumb      = wp_get_attachment_image( $attachment_id, array( 60, 60 ), true, array( 'alt' => '' ) );
        $link_start = '';
        $link_end   = '';

        
Home | Imprint | This part of the site doesn't use cookies.