PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/patricialutz-custom/image.php

https://github.com/misfist/patricia-lutz.com
PHP | 97 lines | 75 code | 10 blank | 12 comment | 13 complexity | 0fc24c75aeeb9f9d6d6ef55fc1dcc500 MD5 | raw file
  1. <?php
  2. /**
  3. * @package WordPress
  4. * @subpackage Chunk
  5. */
  6. get_header(); ?>
  7. <div id="contents">
  8. <?php if ( have_posts() ) : ?>
  9. <?php while ( have_posts() ) : the_post(); ?>
  10. <div <?php post_class(); ?> id="post">
  11. <div class="entry-meta">
  12. <div class="date"><a href="<?php the_permalink(); ?>"><?php the_time( 'M d Y' ); ?></a></div>
  13. <?php if ( comments_open() || ( '0' != get_comments_number() && ! comments_open() ) ) : ?>
  14. <div class="comments"><?php comments_popup_link( __( 'Leave a comment', 'quintus' ), __( '1 Comment', 'quintus' ), __( '% Comments', 'chunk' ) ); ?></div>
  15. <?php endif; ?>
  16. <span class="cat-links">
  17. <?php
  18. $metadata = wp_get_attachment_metadata();
  19. printf( __( '<a href="%1$s" title="Link to full-size image">%2$s &times; %3$s</a> in <a href="%4$s" title="Return to %5$s" rel="gallery">%5$s</a>', 'chunk' ),
  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. </span>
  28. <?php edit_post_link( __( 'Edit', 'chunk' ), '<span class="edit-link">', '</span>' ); ?>
  29. <div class="navigation">
  30. <div class="nav-previous"><?php previous_image_link( array( 60, 60 ) ); ?></div>
  31. <div class="nav-next"><?php next_image_link( array( 60, 60 ) ); ?></div>
  32. </div>
  33. </div>
  34. <div class="main">
  35. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'chunk' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  36. <div class="entry-content">
  37. <?php
  38. /**
  39. * 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,
  40. * 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
  41. */
  42. $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' ) ) );
  43. foreach ( $attachments as $k => $attachment ) {
  44. if ( $attachment->ID == $post->ID )
  45. break;
  46. }
  47. $k++;
  48. // If there is more than 1 attachment in a gallery
  49. if ( count( $attachments ) > 1 ) {
  50. if ( isset( $attachments[ $k ] ) )
  51. // get the URL of the next image attachment
  52. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  53. else
  54. // or get the URL of the first image attachment
  55. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  56. } else {
  57. // or, if there's only 1 image, get the URL of the image
  58. $next_attachment_url = wp_get_attachment_url();
  59. }
  60. ?>
  61. <p>
  62. <a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php echo wp_get_attachment_image( $post->ID, array( 580, 580 ) ); ?></a>
  63. </p>
  64. <?php if ( ! empty( $post->post_excerpt ) ) : ?>
  65. <p><?php the_excerpt(); ?></p>
  66. <?php endif; ?>
  67. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'chunk' ) ); ?>
  68. <?php wp_link_pages( array( 'before' => '<p class="page-link"><span>' . __( 'Pages:', 'chunk' ) . '</span>', 'after' => '</p>' ) ); ?>
  69. </div>
  70. <?php the_tags( '<span class="tag-links"><strong>' . __( 'Tagged', 'chunk' ) . '</strong> ', ', ', '</span>' ); ?>
  71. </div>
  72. </div>
  73. <?php comments_template( '', true ); ?>
  74. <?php endwhile; ?>
  75. <?php else : ?>
  76. <div class="hentry error404">
  77. <div class="postbody text">
  78. <h1><?php _e( 'Nothing Found', 'chunk' ); ?></h1>
  79. <div class="content">
  80. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'chunk' ); ?></p>
  81. <?php get_search_form(); ?>
  82. </div><!-- .content -->
  83. </div><!-- .postbody -->
  84. </div>
  85. <?php endif; ?>
  86. </div><!-- #contents -->
  87. <?php get_footer(); ?>