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

/blog/wp-content/themes/duster/image.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 105 lines | 78 code | 15 blank | 12 comment | 11 complexity | 71a00e576b375f68396435d108c254f6 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @package WordPress
  4. * @subpackage Duster
  5. */
  6. get_header(); ?>
  7. <div id="primary" class="image-attachment">
  8. <div id="content" role="main">
  9. <?php the_post(); ?>
  10. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  11. <header class="entry-header">
  12. <h1 class="entry-title"><?php the_title(); ?></h1>
  13. <div class="entry-meta">
  14. <?php
  15. $metadata = wp_get_attachment_metadata();
  16. 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>', 'duster' ),
  17. esc_attr( get_the_time() ),
  18. get_the_date(),
  19. wp_get_attachment_url(),
  20. $metadata['width'],
  21. $metadata['height'],
  22. get_permalink( $post->post_parent ),
  23. get_the_title( $post->post_parent )
  24. );
  25. ?>
  26. <?php edit_post_link( __( 'Edit', 'duster' ), '<span class="sep">|</span> <span class="edit-link">', '</span>' ); ?>
  27. </div><!-- .entry-meta -->
  28. <nav id="image-navigation">
  29. <span class="previous-image"><?php previous_image_link( false, __( '&larr; Previous' , 'duster' ) ); ?></span>
  30. <span class="next-image"><?php next_image_link( false, __( 'Next &rarr;' , 'duster' ) ); ?></span>
  31. </nav><!-- #image-navigation -->
  32. </header><!-- .entry-header -->
  33. <div class="entry-content">
  34. <div class="entry-attachment">
  35. <div class="attachment">
  36. <?php
  37. /**
  38. * 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,
  39. * 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
  40. */
  41. $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' ) ) );
  42. foreach ( $attachments as $k => $attachment ) {
  43. if ( $attachment->ID == $post->ID )
  44. break;
  45. }
  46. $k++;
  47. // If there is more than 1 attachment in a gallery
  48. if ( count( $attachments ) > 1 ) {
  49. if ( isset( $attachments[ $k ] ) )
  50. // get the URL of the next image attachment
  51. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  52. else
  53. // or get the URL of the first image attachment
  54. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  55. } else {
  56. // or, if there's only 1 image, get the URL of the image
  57. $next_attachment_url = wp_get_attachment_url();
  58. }
  59. ?>
  60. <a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
  61. $attachment_size = apply_filters( 'theme_attachment_size', 800 );
  62. echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height.
  63. ?></a>
  64. </div><!-- .attachment -->
  65. <?php if ( ! empty( $post->post_excerpt ) ) : ?>
  66. <div class="entry-caption">
  67. <?php the_excerpt(); ?>
  68. </div>
  69. <?php endif; ?>
  70. </div><!-- .entry-attachment -->
  71. <?php the_content(); ?>
  72. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'duster' ), 'after' => '</div>' ) ); ?>
  73. </div><!-- .entry-content -->
  74. <div class="entry-utility">
  75. <?php if ( comments_open() && pings_open() ) : // Comments and trackbacks open ?>
  76. <?php printf( __( '<a class="comment-link" href="#respond" title="Post a comment">Post a comment</a> or leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'duster' ), get_trackback_url() ); ?>
  77. <?php elseif ( ! comments_open() && pings_open() ) : // Only trackbacks open ?>
  78. <?php printf( __( 'Comments are closed, but you can leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'duster' ), get_trackback_url() ); ?>
  79. <?php elseif ( comments_open() && ! pings_open() ) : // Only comments open ?>
  80. <?php _e( 'Trackbacks are closed, but you can <a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'duster' ); ?>
  81. <?php elseif ( ! comments_open() && ! pings_open() ) : // Comments and trackbacks closed ?>
  82. <?php _e( 'Both comments and trackbacks are currently closed.', 'duster' ); ?>
  83. <?php endif; ?>
  84. <?php edit_post_link( __( 'Edit', 'duster' ), ' <span class="edit-link">', '</span>' ); ?>
  85. </div><!-- .entry-utility -->
  86. </article><!-- #post-<?php the_ID(); ?> -->
  87. <?php comments_template(); ?>
  88. </div><!-- #content -->
  89. </div><!-- #primary -->
  90. <?php get_footer(); ?>