PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-content/themes/modularity-lite/image.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 91 lines | 63 code | 16 blank | 12 comment | 8 complexity | 49ff856354d5a5e2b7b33290afe5ba9d 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 Modularity
  5. */
  6. ?>
  7. <?php get_header(); ?>
  8. <div class="span-24 last">
  9. <div class="content">
  10. <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  11. <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
  12. <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> &raquo; <?php the_title(); ?></h2>
  13. <div class="entry">
  14. <?php
  15. /**
  16. * 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,
  17. * 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
  18. */
  19. $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' ) ) );
  20. foreach ( $attachments as $k => $attachment ) {
  21. if ( $attachment->ID == $post->ID )
  22. break;
  23. }
  24. $k++;
  25. // If there is more than 1 attachment in a gallery
  26. if ( count( $attachments ) > 1 ) {
  27. if ( isset( $attachments[ $k ] ) )
  28. // get the URL of the next image attachment
  29. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  30. else
  31. // or get the URL of the first image attachment
  32. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  33. } else {
  34. // or, if there's only 1 image, get the URL of the image
  35. $next_attachment_url = wp_get_attachment_url();
  36. }
  37. ?>
  38. <p class="image-attachment"><a href="<?php echo $next_attachment_url; ?>">
  39. <?php echo wp_get_attachment_image( $post->ID, array( 949, 9999 ) ); ?>
  40. </a></p>
  41. <div class="clear"></div>
  42. <div class="caption"><?php if ( !empty($post->post_excerpt) ) the_excerpt(); // this is the "caption" ?></div>
  43. <?php the_content( __( '<p class="serif">Read the rest of this entry &raquo;</p>', 'modularity' ) ); ?>
  44. <div class="navigation">
  45. <div class="alignleft"><?php previous_image_link() ?></div>
  46. <div class="alignright"><?php next_image_link() ?></div>
  47. </div>
  48. <div class="clear"></div>
  49. <p class="postmetadata alt">
  50. <small>
  51. <?php
  52. $metadata = wp_get_attachment_metadata();
  53. 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>', 'modularity'),
  54. esc_attr( get_the_time() ),
  55. get_the_date(),
  56. wp_get_attachment_url(),
  57. $metadata['width'],
  58. $metadata['height'],
  59. get_permalink( $post->post_parent ),
  60. get_the_title( $post->post_parent )
  61. );
  62. ?>
  63. <?php edit_post_link( __( 'Edit', 'modularity' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  64. </small>
  65. </p>
  66. </div>
  67. </div>
  68. <?php comments_template(); ?>
  69. </div>
  70. </div>
  71. <?php endwhile; else: ?>
  72. <p><?php _e( 'Sorry, no attachments matched your criteria.', 'modularity' ); ?></p>
  73. <?php endif; ?>
  74. <!-- Begin Footer -->
  75. <?php get_footer(); ?>