PageRenderTime 96ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 113 lines | 81 code | 19 blank | 13 comment | 10 complexity | f57604c8f3583274568b480f334207cb 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 Coraline
  5. * @since Coraline 1.0
  6. */
  7. get_header(); ?>
  8. <div id="content-container" class="image-attachment">
  9. <div id="content" role="main">
  10. <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  11. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  12. <h2 class="entry-title"><?php the_title(); ?></h2>
  13. <div class="entry-meta">
  14. <?php
  15. if ( ! empty( $post->post_parent ) ) :
  16. $metadata = wp_get_attachment_metadata();
  17. 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>', 'coraline' ),
  18. esc_attr( get_the_time() ),
  19. get_the_date(),
  20. wp_get_attachment_url(),
  21. $metadata['width'],
  22. $metadata['height'],
  23. get_permalink( $post->post_parent ),
  24. get_the_title( $post->post_parent )
  25. );
  26. ?>
  27. <?php edit_post_link( __( 'Edit', 'coraline' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  28. <?php
  29. else :
  30. $metadata = wp_get_attachment_metadata();
  31. printf( __( '<span class="meta-prep meta-prep-entry-date">Uploaded </span> at <a href="%1$s" title="Link to full-size image">%2$s &times; %3$s</a>', 'coraline' ),
  32. wp_get_attachment_url(),
  33. $metadata['width'],
  34. $metadata['height']
  35. );
  36. ?>
  37. <?php edit_post_link( __( 'Edit', 'coraline' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  38. <?php endif; ?>
  39. </div><!-- .entry-meta -->
  40. <div id="image-navigation" class="entry-meta">
  41. <span class="previous-image"><?php previous_image_link( false, __( '&larr; Previous' , 'coraline' ) ); ?></span>
  42. <span class="next-image"><?php next_image_link( false, __( 'Next &rarr;' , 'coraline' ) ); ?></span>
  43. </div><!-- #image-navigation -->
  44. <div class="entry-content">
  45. <div class="entry-attachment">
  46. <div class="attachment">
  47. <?php
  48. /**
  49. * 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,
  50. * 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
  51. */
  52. $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' ) ) );
  53. foreach ( $attachments as $k => $attachment ) {
  54. if ( $attachment->ID == $post->ID )
  55. break;
  56. }
  57. $k++;
  58. // If there is more than 1 attachment in a gallery
  59. if ( count( $attachments ) > 1 ) {
  60. if ( isset( $attachments[ $k ] ) )
  61. // get the URL of the next image attachment
  62. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  63. else
  64. // or get the URL of the first image attachment
  65. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  66. } else {
  67. // or, if there's only 1 image, get the URL of the image
  68. $next_attachment_url = wp_get_attachment_url();
  69. }
  70. ?>
  71. <a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
  72. $attachment_size = apply_filters( 'theme_attachment_size', 800 );
  73. echo wp_get_attachment_image( $post->ID, array( $attachment_size, $attachment_size ) ); // filterable image width with, essentially, no limit for image height.
  74. ?></a>
  75. </div><!-- .attachment -->
  76. <?php if ( ! empty( $post->post_excerpt ) ) : ?>
  77. <div class="entry-caption">
  78. <?php the_excerpt(); ?>
  79. </div>
  80. <?php endif; ?>
  81. </div><!-- .entry-attachment -->
  82. <?php the_content(); ?>
  83. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'coraline' ), 'after' => '</div>' ) ); ?>
  84. </div><!-- .entry-content -->
  85. <div class="entry-info">
  86. <?php coraline_posted_in(); ?>
  87. <?php edit_post_link( __( 'Edit', 'coraline' ), ' <span class="edit-link">', '</span>' ); ?>
  88. </div><!-- .entry-info -->
  89. </div><!-- #post-## -->
  90. <?php comments_template(); ?>
  91. <?php endwhile; ?>
  92. </div><!-- #content -->
  93. </div><!-- #content-container -->
  94. <?php get_footer(); ?>