PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/image.php

https://github.com/tomtom10/required-foundation
PHP | 104 lines | 71 code | 19 blank | 14 comment | 7 complexity | c3b046b53e7aa428d80a710f09307774 MD5 | raw file
  1. <?php
  2. /**
  3. * The template for displaying image attachments.
  4. *
  5. * @package required+ Foundation
  6. * @since required+ Foundation 0.1.0
  7. */
  8. get_header(); ?>
  9. <div id="content" class="row">
  10. <div id="main" class="twelve columns" role="main">
  11. <div class="post-box">
  12. <?php while ( have_posts() ) : the_post(); ?>
  13. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  14. <header class="entry-header">
  15. <h1 class="entry-title"><?php the_title(); ?></h1>
  16. <div class="entry-meta">
  17. <?php
  18. $metadata = wp_get_attachment_metadata();
  19. printf( __( '<span class="meta-prep meta-prep-entry-date">Published </span> <span class="entry-date"><abbr class="published" title="%1$s">%2$s</abbr></span> at <a href="%3$s" title="Link to full-size image">%4$s &times; %5$s</a> in <a href="%6$s" title="Return to %7$s" rel="gallery">%7$s</a>', 'requiredfoundation' ),
  20. esc_attr( get_the_time() ),
  21. get_the_date(),
  22. esc_url( wp_get_attachment_url() ),
  23. $metadata['width'],
  24. $metadata['height'],
  25. esc_url( get_permalink( $post->post_parent ) ),
  26. get_the_title( $post->post_parent )
  27. );
  28. ?>
  29. </div><!-- .entry-meta -->
  30. </header><!-- .entry-header -->
  31. <nav class="nav-single">
  32. <h3 class="assistive-text"><?php _e( 'Image navigation', 'requiredfoundation' ); ?></h3>
  33. <span class="nav-previous"><?php previous_image_link( false, __( '&larr; Previous' , 'requiredfoundation' ) ); ?></span>
  34. <span class="nav-next"><?php next_image_link( false, __( 'Next &rarr;' , 'requiredfoundation' ) ); ?></span>
  35. </nav><!-- .nav-single -->
  36. <div class="entry-content">
  37. <div class="entry-attachment">
  38. <div class="attachment">
  39. <?php
  40. /**
  41. * Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
  42. * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
  43. */
  44. $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
  45. foreach ( $attachments as $k => $attachment ) {
  46. if ( $attachment->ID == $post->ID )
  47. break;
  48. }
  49. $k++;
  50. // If there is more than 1 attachment in a gallery
  51. if ( count( $attachments ) > 1 ) {
  52. if ( isset( $attachments[ $k ] ) )
  53. // get the URL of the next image attachment
  54. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  55. else
  56. // or get the URL of the first image attachment
  57. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  58. } else {
  59. // or, if there's only 1 image, get the URL of the image
  60. $next_attachment_url = wp_get_attachment_url();
  61. }
  62. ?>
  63. <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
  64. $attachment_size = apply_filters( 'required_attachment_size', 848 );
  65. echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height.
  66. ?></a>
  67. <?php if ( ! empty( $post->post_excerpt ) ) : ?>
  68. <div class="entry-caption">
  69. <?php the_excerpt(); ?>
  70. </div>
  71. <?php endif; ?>
  72. </div><!-- .attachment -->
  73. </div><!-- .entry-attachment -->
  74. <div class="entry-description">
  75. <?php the_content(); ?>
  76. <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'requiredfoundation' ) . '</span>', 'after' => '</div>' ) ); ?>
  77. </div><!-- .entry-description -->
  78. </div><!-- .entry-content -->
  79. </article><!-- #post-<?php the_ID(); ?> -->
  80. <?php comments_template(); ?>
  81. <?php endwhile; // end of the loop. ?>
  82. </div><!-- #content -->
  83. </div><!-- #primary -->
  84. </div>
  85. <?php get_footer(); ?>