image.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * The template for displaying image attachments
  4. *
  5. * @package WordPress
  6. * @subpackage Twenty_Sixteen
  7. * @since Twenty Sixteen 1.0
  8. */
  9. get_header(); ?>
  10. <div id="primary" class="content-area">
  11. <main id="main" class="site-main" role="main">
  12. <?php
  13. // Start the loop.
  14. while ( have_posts() ) : the_post();
  15. ?>
  16. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  17. <nav id="image-navigation" class="navigation image-navigation">
  18. <div class="nav-links">
  19. <div class="nav-previous"><?php previous_image_link( false, __( 'Previous Image', 'twentysixteen' ) ); ?></div>
  20. <div class="nav-next"><?php next_image_link( false, __( 'Next Image', 'twentysixteen' ) ); ?></div>
  21. </div><!-- .nav-links -->
  22. </nav><!-- .image-navigation -->
  23. <header class="entry-header">
  24. <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
  25. </header><!-- .entry-header -->
  26. <div class="entry-content">
  27. <div class="entry-attachment">
  28. <?php
  29. /**
  30. * Filter the default twentysixteen image attachment size.
  31. *
  32. * @since Twenty Sixteen 1.0
  33. *
  34. * @param string $image_size Image size. Default 'large'.
  35. */
  36. $image_size = apply_filters( 'twentysixteen_attachment_size', 'large' );
  37. echo wp_get_attachment_image( get_the_ID(), $image_size );
  38. ?>
  39. <?php twentysixteen_excerpt( 'entry-caption' ); ?>
  40. </div><!-- .entry-attachment -->
  41. <?php
  42. the_content();
  43. wp_link_pages( array(
  44. 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentysixteen' ) . '</span>',
  45. 'after' => '</div>',
  46. 'link_before' => '<span>',
  47. 'link_after' => '</span>',
  48. 'pagelink' => '<span class="screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>%',
  49. 'separator' => '<span class="screen-reader-text">, </span>',
  50. ) );
  51. ?>
  52. </div><!-- .entry-content -->
  53. <footer class="entry-footer">
  54. <?php twentysixteen_entry_meta(); ?>
  55. <?php
  56. // Retrieve attachment metadata.
  57. $metadata = wp_get_attachment_metadata();
  58. if ( $metadata ) {
  59. printf( '<span class="full-size-link"><span class="screen-reader-text">%1$s </span><a href="%2$s">%3$s &times; %4$s</a></span>',
  60. esc_html_x( 'Full size', 'Used before full size attachment link.', 'twentysixteen' ),
  61. esc_url( wp_get_attachment_url() ),
  62. absint( $metadata['width'] ),
  63. absint( $metadata['height'] )
  64. );
  65. }
  66. ?>
  67. <?php
  68. edit_post_link(
  69. sprintf(
  70. /* translators: %s: Name of current post */
  71. __( 'Edit %s', 'twentysixteen' ),
  72. the_title( '<span class="screen-reader-text">', '</span>', false )
  73. ),
  74. '<span class="edit-link">',
  75. '</span>'
  76. );
  77. ?>
  78. </footer><!-- .entry-footer -->
  79. </article><!-- #post-## -->
  80. <?php
  81. // If comments are open or we have at least one comment, load up the comment template.
  82. if ( comments_open() || get_comments_number() ) {
  83. comments_template();
  84. }
  85. // Parent post navigation.
  86. the_post_navigation( array(
  87. 'prev_text' => _x( '<span class="meta-nav">Published in</span><span class="post-title">%title</span>', 'Parent post link', 'twentysixteen' ),
  88. ) );
  89. // End the loop.
  90. endwhile;
  91. ?>
  92. </main><!-- .site-main -->
  93. </div><!-- .content-area -->
  94. <?php get_sidebar(); ?>
  95. <?php get_footer(); ?>