PageRenderTime 124ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-content/themes/pilcrow/loop-image.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 101 lines | 68 code | 14 blank | 19 comment | 7 complexity | 35b73aabcc6d6d3581e7b75ddda27f15 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * The loop that displays an attachment.
  4. *
  5. * The loop displays the posts and the post content. See
  6. * http://codex.wordpress.org/The_Loop to understand it and
  7. * http://codex.wordpress.org/Template_Tags to understand
  8. * the tags used in it.
  9. *
  10. * This can be overridden in child themes with loop-image.php.
  11. *
  12. * @package WordPress
  13. * @subpackage Pilcrow
  14. * @since Pilcrow 1.0
  15. */
  16. ?>
  17. <?php the_post(); ?>
  18. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  19. <div class="entry-meta">
  20. <?php
  21. printf( __( 'Published %1$s', 'pilcrow' ),
  22. sprintf( '<span class="entry-date"><abbr class="published" title="%1$s">%2$s</abbr></span>',
  23. esc_attr( get_the_time() ),
  24. get_the_date()
  25. )
  26. );
  27. // Let's make sure we have a post parent for this image before we try and print a link to it
  28. if ( ! empty( $post->post_parent ) ) :
  29. printf( __( ' in %1$s', 'pilcrow' ),
  30. sprintf( '<a href="%1$s" title="%2$s" rel="gallery">%3$s</a>',
  31. get_permalink( $post->post_parent ),
  32. esc_attr( sprintf( __( 'Return to %s', 'pilcrow' ), get_the_title( $post->post_parent ) ) ),
  33. get_the_title( $post->post_parent )
  34. )
  35. );
  36. endif; // end the check for the post parent
  37. echo ' <span class="meta-sep">|</span> ';
  38. $metadata = wp_get_attachment_metadata();
  39. printf( __( 'Full size is %s pixels', 'pilcrow' ),
  40. sprintf( '<a href="%1$s" title="%2$s">%3$s &times; %4$s</a>',
  41. wp_get_attachment_url(),
  42. esc_attr( __( 'Link to full-size image', 'pilcrow' ) ),
  43. $metadata['width'],
  44. $metadata['height']
  45. )
  46. );
  47. edit_post_link( __( 'Edit', 'pilcrow' ), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>' );
  48. ?>
  49. </div><!-- .entry-meta -->
  50. <div id="image-navigation">
  51. <span class="previous-image"><?php previous_image_link( false, __( '&larr; Previous' , 'pilcrow' ) ); ?></span>
  52. <span class="next-image"><?php next_image_link( false, __( 'Next &rarr;' , 'pilcrow' ) ); ?></span>
  53. </div><!-- #image-navigation -->
  54. <h2 class="entry-title"><?php the_title(); ?></h2>
  55. <div class="entry entry-content">
  56. <div class="entry-attachment">
  57. <?php
  58. $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' ) ) );
  59. foreach ( $attachments as $k => $attachment ) {
  60. if ( $attachment->ID == $post->ID )
  61. break;
  62. }
  63. $k++;
  64. // If there is more than 1 image attachment in a gallery
  65. if ( count( $attachments ) > 1 ) {
  66. if ( isset( $attachments[ $k ] ) )
  67. // get the URL of the next image attachment
  68. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  69. else
  70. // or get the URL of the first image attachment
  71. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  72. } else {
  73. // or, if there's only 1 image attachment, get the URL of the image
  74. $next_attachment_url = wp_get_attachment_url();
  75. }
  76. ?>
  77. <p class="attachment"><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
  78. $attachment_size = apply_filters( 'pilcrow_attachment_size', 900 );
  79. echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height.
  80. ?></a></p>
  81. </div><!-- .entry-attachment -->
  82. <div class="entry-caption"><?php if ( !empty( $post->post_excerpt ) ) the_excerpt(); ?></div>
  83. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'pilcrow' ) ); ?>
  84. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'pilcrow' ), 'after' => '</div>' ) ); ?>
  85. </div><!-- .entry-content -->
  86. </div><!-- #post-## -->
  87. <?php comments_template(); ?>