[ Index ]

PHP Cross Reference of WordPress

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 1.0.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                   * @param string $image_size Image size. Default 'large'.
  28                   */
  29                  $image_size = apply_filters( 'twenty_twenty_one_attachment_size', 'full' );
  30                  echo wp_get_attachment_image( get_the_ID(), $image_size );
  31                  ?>
  32  
  33                  <?php if ( wp_get_attachment_caption() ) : ?>
  34                      <figcaption class="wp-caption-text"><?php echo wp_kses_post( wp_get_attachment_caption() ); ?></figcaption>
  35                  <?php endif; ?>
  36              </figure><!-- .wp-block-image -->
  37  
  38              <?php
  39              the_content();
  40  
  41              wp_link_pages(
  42                  array(
  43                      'before'   => '<nav class="page-links" aria-label="' . esc_attr__( 'Page', 'twentytwentyone' ) . '">',
  44                      'after'    => '</nav>',
  45                      /* translators: %: page number. */
  46                      'pagelink' => esc_html__( 'Page %', 'twentytwentyone' ),
  47                  )
  48              );
  49              ?>
  50          </div><!-- .entry-content -->
  51  
  52          <footer class="entry-footer default-max-width">
  53              <?php
  54              // Check if there is a parent, then add the published in link.
  55              if ( wp_get_post_parent_id( $post ) ) {
  56                  echo '<span class="posted-on">';
  57                  printf(
  58                      /* translators: %s: parent post. */
  59                      esc_html__( 'Published in %s', 'twentytwentyone' ),
  60                      '<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>'
  61                  );
  62                  echo '</span>';
  63              } else {
  64                  // Edit post link.
  65                  edit_post_link(
  66                      sprintf(
  67                          /* translators: %s: Name of current post. Only visible to screen readers. */
  68                          esc_html__( 'Edit %s', 'twentytwentyone' ),
  69                          '<span class="screen-reader-text">' . get_the_title() . '</span>'
  70                      ),
  71                      '<span class="edit-link">',
  72                      '</span>'
  73                  );
  74              }
  75  
  76              // Retrieve attachment metadata.
  77              $metadata = wp_get_attachment_metadata();
  78              if ( $metadata ) {
  79                  printf(
  80                      '<span class="full-size-link"><span class="screen-reader-text">%1$s</span><a href="%2$s">%3$s &times; %4$s</a></span>',
  81                      esc_html_x( 'Full size', 'Used before full size attachment link.', 'twentytwentyone' ), // phpcs:ignore WordPress.Security.EscapeOutput
  82                      esc_url( wp_get_attachment_url() ),
  83                      absint( $metadata['width'] ),
  84                      absint( $metadata['height'] )
  85                  );
  86              }
  87  
  88              if ( wp_get_post_parent_id( $post ) ) {
  89                  // Edit post link.
  90                  edit_post_link(
  91                      sprintf(
  92                          /* translators: %s: Name of current post. Only visible to screen readers. */
  93                          esc_html__( 'Edit %s', 'twentytwentyone' ),
  94                          '<span class="screen-reader-text">' . get_the_title() . '</span>'
  95                      ),
  96                      '<span class="edit-link">',
  97                      '</span><br>'
  98                  );
  99              }
 100              ?>
 101          </footer><!-- .entry-footer -->
 102      </article><!-- #post-## -->
 103      <?php
 104      // If comments are open or there is at least one comment, load up the comment template.
 105      if ( comments_open() || get_comments_number() ) {
 106          comments_template();
 107      }
 108  } // End the loop.
 109  
 110  get_footer();


Generated: Fri Dec 4 01:00:03 2020 Cross-referenced by PHPXref 0.7.1