You appear to be a bot. Output may be restricted
Description
Displays an optional post thumbnail.
Wraps the post thumbnail in an anchor element on index views, or a div element when on single views.
Usage
$void = twenty_twenty_one_post_thumbnail();
Parameters
Returns
void
Source
File name: twentytwentyone/inc/template-tags.php
Lines:
1 to 34 of 34
function twenty_twenty_one_post_thumbnail() { if ( ! twenty_twenty_one_can_show_post_thumbnail() ) { return; } ?> <?php if ( is_singular() ) : ?> <figure class="post-thumbnail"> <?php // Lazy-loading attributes should be skipped for thumbnails since they are immediately in the viewport. the_post_thumbnail( 'post-thumbnail', array( 'loading' => false ) ); ?> <?php if ( wp_get_attachment_caption( get_post_thumbnail_id() ) ) : ?> <figcaption class="wp-caption-text"><?php echo wp_kses_post( wp_get_attachment_caption( get_post_thumbnail_id() ) ); ?></figcaption> <?php endif; ?> </figure><!-- .post-thumbnail --> <?php else : ?> <figure class="post-thumbnail"> <a class="post-thumbnail-inner alignwide" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1"> <?php the_post_thumbnail( 'post-thumbnail' ); ?> </a> <?php if ( wp_get_attachment_caption( get_post_thumbnail_id() ) ) : ?> <figcaption class="wp-caption-text"><?php echo wp_kses_post( wp_get_attachment_caption( get_post_thumbnail_id() ) ); ?></figcaption> <?php endif; ?> </figure><!-- .post-thumbnail --> <?php endif; ?> <?php }