[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentytwentyone/ -> image.php (source)

   1  <?php
   2  /**
   3   * The template for displaying image attachments
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Twenty_One
   7   * @since Twenty Twenty-One 1.0
   8   */
   9  
  10  get_header();
  11  
  12  // Start the loop.
  13  while ( have_posts() ) {
  14      the_post();
  15      ?>
  16      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  17          <header class="entry-header alignwide">
  18              <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
  19          </header><!-- .entry-header -->
  20  
  21          <div class="entry-content">
  22              <figure class="wp-block-image">
  23                  <?php
  24                  /**
  25                   * Filter the default image attachment size.
  26                   *
  27                   * @since Twenty Twenty-One 1.0
  28                   *
  29                   * @param string $image_size Image size. Default 'full'.
  30                   */
  31                  $image_size = apply_filters( 'twenty_twenty_one_attachment_size', 'full' );
  32                  echo wp_get_attachment_image( get_the_ID(), $image_size );
  33                  ?>
  34  
  35                  <?php if ( wp_get_attachment_caption() ) : ?>
  36                      <figcaption class="wp-caption-text"><?php echo wp_kses_post( wp_get_attachment_caption() ); ?></figcaption>
  37                  <?php endif; ?>
  38              </figure><!-- .wp-block-image -->
  39  
  40              <?php
  41              the_content();
  42  
  43              wp_link_pages(
  44                  array(
  45                      'before'   => '<nav class="page-links" aria-label="' . esc_attr__( 'Page', 'twentytwentyone' ) . '">',
  46                      'after'    => '</nav>',
  47                      /* translators: %: Page number. */
  48                      'pagelink' => esc_html__( 'Page %', 'twentytwentyone' ),
  49                  )
  50              );
  51              ?>
  52          </div><!-- .entry-content -->
  53  
  54          <footer class="entry-footer default-max-width">
  55              <?php
  56              // Check if there is a parent, then add the published in link.
  57              if ( wp_get_post_parent_id( $post ) ) {
  58                  echo '<span class="posted-on">';
  59                  printf(
  60                      /* translators: %s: Parent post. */
  61                      esc_html__( 'Published in %s', 'twentytwentyone' ),
  62                      '<a href="' . esc_url( get_the_permalink( wp_get_post_parent_id( $post ) ) ) . '">' . esc_html( get_the_title( wp_get_post_parent_id( $post ) ) ) . '</a>'
  63                  );
  64                  echo '</span>';
  65              } else {
  66                  // Edit post link.
  67                  edit_post_link(
  68                      sprintf(
  69                          /* translators: %s: Post title. Only visible to screen readers. */
  70                          esc_html__( 'Edit %s', 'twentytwentyone' ),
  71                          '<span class="screen-reader-text">' . get_the_title() . '</span>'
  72                      ),
  73                      '<span class="edit-link">',
  74                      '</span>'
  75                  );
  76              }
  77  
  78              // Retrieve attachment metadata.
  79              $metadata = wp_get_attachment_metadata();
  80              if ( $metadata ) {
  81                  printf(
  82                      '<span class="full-size-link"><span class="screen-reader-text">%1$s</span><a href="%2$s">%3$s &times; %4$s</a></span>',
  83                      /* translators: Hidden accessibility text. */
  84                      esc_html_x( 'Full size', 'Used before full size attachment link.', 'twentytwentyone' ), // phpcs:ignore WordPress.Security.EscapeOutput
  85                      esc_url( wp_get_attachment_url() ),
  86                      absint( $metadata['width'] ),
  87                      absint( $metadata['height'] )
  88                  );
  89              }
  90  
  91              if ( wp_get_post_parent_id( $post ) ) {
  92                  // Edit post link.
  93                  edit_post_link(
  94                      sprintf(
  95                          /* translators: %s: Post title. Only visible to screen readers. */
  96                          esc_html__( 'Edit %s', 'twentytwentyone' ),
  97                          '<span class="screen-reader-text">' . get_the_title() . '</span>'
  98                      ),
  99                      '<span class="edit-link">',
 100                      '</span><br>'
 101                  );
 102              }
 103              ?>
 104          </footer><!-- .entry-footer -->
 105      </article><!-- #post-<?php the_ID(); ?> -->
 106      <?php
 107      // If comments are open or there is at least one comment, load up the comment template.
 108      if ( comments_open() || get_comments_number() ) {
 109          comments_template();
 110      }
 111  } // End the loop.
 112  
 113  get_footer();


Generated : Wed Dec 25 08:20:01 2024 Cross-referenced by PHPXref