PageRenderTime 57ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/wp-content/themes/twentyeleven/image.php

https://bitbucket.org/dkrzos/phc
PHP | 104 lines | 71 code | 18 blank | 15 comment | 7 complexity | 1bdd900e491ffda3ccd2b2106929b2b9 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * The template for displaying image attachments.
  4. *
  5. * @package WordPress
  6. * @subpackage Twenty_Eleven
  7. * @since Twenty Eleven 1.0
  8. */
  9. get_header(); ?>
  10. <div id="primary" class="image-attachment">
  11. <div id="content" role="main">
  12. <?php while ( have_posts() ) : the_post(); ?>
  13. <nav id="nav-single">
  14. <h3 class="assistive-text"><?php _e( 'Image navigation', 'twentyeleven' ); ?></h3>
  15. <span class="nav-previous"><?php previous_image_link( false, __( '&larr; Previous' , 'twentyeleven' ) ); ?></span>
  16. <span class="nav-next"><?php next_image_link( false, __( 'Next &rarr;' , 'twentyeleven' ) ); ?></span>
  17. </nav><!-- #nav-single -->
  18. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  19. <header class="entry-header">
  20. <h1 class="entry-title"><?php the_title(); ?></h1>
  21. <div class="entry-meta">
  22. <?php
  23. $metadata = wp_get_attachment_metadata();
  24. 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">%8$s</a>', 'twentyeleven' ),
  25. esc_attr( get_the_time() ),
  26. get_the_date(),
  27. esc_url( wp_get_attachment_url() ),
  28. $metadata['width'],
  29. $metadata['height'],
  30. esc_url( get_permalink( $post->post_parent ) ),
  31. esc_attr( strip_tags( get_the_title( $post->post_parent ) ) ),
  32. get_the_title( $post->post_parent )
  33. );
  34. ?>
  35. <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
  36. </div><!-- .entry-meta -->
  37. </header><!-- .entry-header -->
  38. <div class="entry-content">
  39. <div class="entry-attachment">
  40. <div class="attachment">
  41. <?php
  42. /**
  43. * 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,
  44. * 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
  45. */
  46. $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' ) ) );
  47. foreach ( $attachments as $k => $attachment ) {
  48. if ( $attachment->ID == $post->ID )
  49. break;
  50. }
  51. $k++;
  52. // If there is more than 1 attachment in a gallery
  53. if ( count( $attachments ) > 1 ) {
  54. if ( isset( $attachments[ $k ] ) )
  55. // get the URL of the next image attachment
  56. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  57. else
  58. // or get the URL of the first image attachment
  59. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  60. } else {
  61. // or, if there's only 1 image, get the URL of the image
  62. $next_attachment_url = wp_get_attachment_url();
  63. }
  64. ?>
  65. <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php
  66. $attachment_size = apply_filters( 'twentyeleven_attachment_size', 848 );
  67. echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height.
  68. ?></a>
  69. <?php if ( ! empty( $post->post_excerpt ) ) : ?>
  70. <div class="entry-caption">
  71. <?php the_excerpt(); ?>
  72. </div>
  73. <?php endif; ?>
  74. </div><!-- .attachment -->
  75. </div><!-- .entry-attachment -->
  76. <div class="entry-description">
  77. <?php the_content(); ?>
  78. <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
  79. </div><!-- .entry-description -->
  80. </div><!-- .entry-content -->
  81. </article><!-- #post-<?php the_ID(); ?> -->
  82. <?php comments_template(); ?>
  83. <?php endwhile; // end of the loop. ?>
  84. </div><!-- #content -->
  85. </div><!-- #primary -->
  86. <?php get_footer(); ?>