featured-image.php 883 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Displays the featured image
  4. *
  5. * @package WordPress
  6. * @subpackage Twenty_Twenty
  7. * @since Twenty Twenty 1.0
  8. */
  9. if ( has_post_thumbnail() && ! post_password_required() ) {
  10. $featured_media_inner_classes = '';
  11. // Make the featured media thinner on archive pages.
  12. if ( ! is_singular() ) {
  13. $featured_media_inner_classes .= ' medium';
  14. }
  15. ?>
  16. <figure class="featured-media">
  17. <div class="featured-media-inner section-inner<?php echo $featured_media_inner_classes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>">
  18. <?php
  19. the_post_thumbnail();
  20. $caption = get_the_post_thumbnail_caption();
  21. if ( $caption ) {
  22. ?>
  23. <figcaption class="wp-caption-text"><?php echo esc_html( $caption ); ?></figcaption>
  24. <?php
  25. }
  26. ?>
  27. </div><!-- .featured-media-inner -->
  28. </figure><!-- .featured-media -->
  29. <?php
  30. }