PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 95 lines | 69 code | 18 blank | 8 comment | 6 complexity | a694cf64c7b678f4639feccefd39262c MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php get_header(); ?>
  2. <div id="body" class="full">
  3. <div id="content">
  4. <?php the_post(); ?>
  5. <div id="nav-above" class="navigation">
  6. <div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">&lsaquo;</span> %title' ) ?></div>
  7. <div class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">&rsaquo;</span>' ) ?></div>
  8. </div><!-- #nav-above -->
  9. <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
  10. <h2 class="post-title">
  11. <span class="wrap">
  12. <span class="posted"><?php the_time(get_option("date_format")); ?></span>
  13. <span class="title"><?php the_title(); ?></span>
  14. </span>
  15. </h2>
  16. <div class="contentblock">
  17. <?php
  18. /**
  19. * 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,
  20. * 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
  21. */
  22. $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' ) ) );
  23. foreach ( $attachments as $k => $attachment ) {
  24. if ( $attachment->ID == $post->ID )
  25. break;
  26. }
  27. $k++;
  28. // If there is more than 1 attachment in a gallery
  29. if ( count( $attachments ) > 1 ) {
  30. if ( isset( $attachments[ $k ] ) )
  31. // get the URL of the next image attachment
  32. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  33. else
  34. // or get the URL of the first image attachment
  35. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  36. } else {
  37. // or, if there's only 1 image, get the URL of the image
  38. $next_attachment_url = wp_get_attachment_url();
  39. }
  40. ?>
  41. <p><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
  42. $attachment_size = apply_filters( 'theme_attachment_size', 860 );
  43. echo wp_get_attachment_image( $post->ID, array( $attachment_size, $attachment_size ) );
  44. ?></a></p>
  45. <?php if (has_excerpt()) : ?>
  46. <div id="intro">
  47. <?php the_excerpt(); ?>
  48. </div><!-- #intro -->
  49. <?php endif; ?>
  50. <?php the_content(''); ?>
  51. <div class="image-navigation">
  52. <span class="previous-image alignleft"><?php previous_image_link( false, __( '&larr; Previous' , 'steira' ) ); ?></span>
  53. <span class="next-image alignright"><?php next_image_link( false, __( 'Next &rarr;' , 'steira' ) ); ?></span>
  54. </div>
  55. <?php wp_link_pages('before=<p class="page-link">' . __( 'Pages:', 'steira' ) . '&after=</p>') ?>
  56. <p><?php the_tags(__( 'Tags: ', 'steira' ), ', ', ''); ?></p>
  57. </div><!-- contentblock -->
  58. <div class="postdetails">
  59. <?php
  60. $metadata = wp_get_attachment_metadata();
  61. 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>', 'steira' ),
  62. esc_attr( get_the_time() ),
  63. get_the_date(),
  64. wp_get_attachment_url(),
  65. $metadata['width'],
  66. $metadata['height'],
  67. get_permalink( $post->post_parent ),
  68. get_the_title( $post->post_parent )
  69. );
  70. ?>
  71. <?php edit_post_link( __( 'Edit', 'steira' ), '<span class="sep">|</span> <span class="edit-link">', '</span>' ); ?>
  72. </div>
  73. </div><!-- #post-<?php the_ID(); ?> -->
  74. </div><!-- content -->
  75. <?php get_sidebar(); ?>
  76. </div><!-- body -->
  77. <?php get_footer(); ?>