image.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * The template that shows an attachment image
  4. *
  5. * @package Rebalance
  6. */
  7. get_header(); ?>
  8. <div id="primary" class="content-area">
  9. <main id="main" class="site-main" role="main">
  10. <?php
  11. // Start the loop.
  12. while ( have_posts() ) : the_post();
  13. ?>
  14. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  15. <header class="entry-header">
  16. <?php if ( get_the_title() ) : ?>
  17. <h1 class="entry-title"><a href="<?php echo esc_url(get_permalink()); ?>"><?php the_title(); ?></a></h1>
  18. <?php endif; ?>
  19. <div class="entry-meta">
  20. <?php
  21. $published_text = '<span class="attachment-meta"><time class="entry-date" datetime="%1$s">%2$s</time></span> <span class="parent-entry"><a href="%3$s" title="'. esc_attr__( 'Return to %4$s', 'rebalance' ) . '" rel="gallery">' . esc_html__( 'Return to: %5$s', 'rebalance' ) . '</a></span>';
  22. $post_title = get_the_title( $post->post_parent );
  23. if ( empty( $post_title ) || 0 == $post->post_parent )
  24. $published_text = '<span class="attachment-meta"><time class="entry-date" datetime="%1$s">%2$s</time></span>';
  25. printf( $published_text,
  26. esc_attr( get_the_date('c') ),
  27. esc_html( get_the_date() ),
  28. esc_url( get_permalink( $post->post_parent ) ),
  29. esc_attr( strip_tags( $post_title ) ),
  30. $post_title
  31. );
  32. $metadata = wp_get_attachment_metadata();
  33. printf( '<span class="attachment-meta full-size-link post-comments"><a href="%1$s" title="%2$s">%3$s (%4$s &times; %5$s)</a></span>',
  34. esc_url( wp_get_attachment_url() ),
  35. esc_attr__( 'Link to full-size image', 'rebalance' ),
  36. esc_html__( 'Full resolution', 'rebalance' ),
  37. $metadata['width'],
  38. $metadata['height']
  39. );
  40. edit_post_link( esc_html__( 'Edit', 'rebalance' ), '<span class="edit-link">', '</span>');
  41. ?>
  42. </div> <!-- /post-meta -->
  43. <?php if ( $post->post_parent ) { ?>
  44. <nav class="navigation image-navigation post-navigation" role="navigation">
  45. <h2 class="screen-reader-text">Image navigation</h2>
  46. <div class="nav-links">
  47. <?php // If Previous image exists, show a link
  48. ob_start();
  49. previous_image_link();
  50. $previous_link = ob_get_contents();
  51. ob_end_clean();
  52. if ( $previous_link != '' ) { ?>
  53. <div class="nav-previous"><?php previous_image_link( false, '<span class="meta-nav" aria-hidden="true">' . esc_html__( 'Previous Image', 'rebalance' ) . '</span>' ); ?></div>
  54. <?php } ?>
  55. <?php // If Next image exists, show a link
  56. ob_start();
  57. next_image_link();
  58. $next_link = ob_get_contents();
  59. ob_end_clean();
  60. if ( $next_link != '' ) { ?>
  61. <div class="nav-next"><?php next_image_link( false, '<span class="meta-nav" aria-hidden="true">' . esc_html__( 'Next Image', 'rebalance' ) . '</span>' ); ?></div>
  62. <?php } ?>
  63. </div><!-- .nav-links -->
  64. </nav><!-- .image-navigation -->
  65. <?php } ?>
  66. </header> <!-- /entry-header -->
  67. <div class="post-hero-image clear-fix">
  68. <figure class="entry-image">
  69. <?php rebalance_the_attached_image(); ?>
  70. <?php if ( has_excerpt() ) : ?>
  71. <figcaption class="entry-image-caption"><span class="fa fw fa-camera"></span><?php echo get_the_excerpt(); ?></figcaption>
  72. <?php endif; ?>
  73. </figure>
  74. </div><!-- .post-hero-image -->
  75. <div class="entry-content">
  76. <?php
  77. $attachment = get_post( get_the_ID() ); // Get post by ID
  78. $attachment_content = $attachment->post_content;
  79. $attachment_content = apply_filters( 'the_content', $attachment_content );
  80. echo $attachment_content; ?>
  81. </div><!-- .entry-content -->
  82. </article> <!-- /post -->
  83. <?php // End the loop.
  84. endwhile; ?>
  85. </main><!-- #main -->
  86. </div><!-- #primary -->
  87. <?php get_sidebar(); ?>
  88. <?php get_footer(); ?>