[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
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 × %4$s</a></span>', 83 esc_html_x( 'Full size', 'Used before full size attachment link.', 'twentytwentyone' ), // phpcs:ignore WordPress.Security.EscapeOutput 84 esc_url( wp_get_attachment_url() ), 85 absint( $metadata['width'] ), 86 absint( $metadata['height'] ) 87 ); 88 } 89 90 if ( wp_get_post_parent_id( $post ) ) { 91 // Edit post link. 92 edit_post_link( 93 sprintf( 94 /* translators: %s: Post title. Only visible to screen readers. */ 95 esc_html__( 'Edit %s', 'twentytwentyone' ), 96 '<span class="screen-reader-text">' . get_the_title() . '</span>' 97 ), 98 '<span class="edit-link">', 99 '</span><br>' 100 ); 101 } 102 ?> 103 </footer><!-- .entry-footer --> 104 </article><!-- #post-<?php the_ID(); ?> --> 105 <?php 106 // If comments are open or there is at least one comment, load up the comment template. 107 if ( comments_open() || get_comments_number() ) { 108 comments_template(); 109 } 110 } // End the loop. 111 112 get_footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 5 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |