PageRenderTime 32ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/Starkers/attachment.php

https://github.com/aspaceafo/aspace-theme
PHP | 98 lines | 74 code | 12 blank | 12 comment | 11 complexity | 037146a4f5bb1cd3a9d48e2e5feb18c2 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. * The template for displaying attachments.
  4. *
  5. * @package WordPress
  6. * @subpackage Starkers
  7. * @since Starkers 3.0
  8. */
  9. get_header(); ?>
  10. <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  11. <p><a href="<?php echo get_permalink( $post->post_parent ); ?>" title="<?php esc_attr( printf( __( 'Return to %s', 'twentyten' ), get_the_title( $post->post_parent ) ) ); ?>" rel="gallery"><?php
  12. /* translators: %s - title of parent post */
  13. printf( __( '<span>&larr;</span> %s', 'twentyten' ), get_the_title( $post->post_parent ) );
  14. ?></a></p>
  15. <h2><?php the_title(); ?></h2>
  16. <?php
  17. printf(__('By %2$s', 'twentyten'),
  18. 'meta-prep meta-prep-author',
  19. sprintf( '<a class="url fn n" href="%1$s" title="%2$s">%3$s</a>',
  20. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  21. sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
  22. get_the_author()
  23. )
  24. );
  25. ?>
  26. <span>|</span>
  27. <?php
  28. printf( __('Published %2$s', 'twentyten'),
  29. 'meta-prep meta-prep-entry-date',
  30. sprintf( '<abbr title="%1$s">%2$s</abbr>',
  31. esc_attr( get_the_time() ),
  32. get_the_date()
  33. )
  34. );
  35. if ( wp_attachment_is_image() ) {
  36. echo ' | ';
  37. $metadata = wp_get_attachment_metadata();
  38. printf( __( 'Full size is %s pixels', 'twentyten'),
  39. sprintf( '<a href="%1$s" title="%2$s">%3$s &times; %4$s</a>',
  40. wp_get_attachment_url(),
  41. esc_attr( __('Link to full-size image', 'twentyten') ),
  42. $metadata['width'],
  43. $metadata['height']
  44. )
  45. );
  46. }
  47. ?>
  48. <?php edit_post_link( __( 'Edit', 'twentyten' ), '', '' ); ?>
  49. </div><!-- .entry-meta -->
  50. <?php if ( wp_attachment_is_image() ) :
  51. $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' ) ) );
  52. foreach ( $attachments as $k => $attachment ) {
  53. if ( $attachment->ID == $post->ID )
  54. break;
  55. }
  56. $k++;
  57. // If there is more than 1 image attachment in a gallery
  58. if ( count( $attachments ) > 1 ) {
  59. if ( isset( $attachments[ $k ] ) )
  60. // get the URL of the next image attachment
  61. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  62. else
  63. // or get the URL of the first image attachment
  64. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  65. } else {
  66. // or, if there's only 1 image attachment, get the URL of the image
  67. $next_attachment_url = wp_get_attachment_url();
  68. }
  69. ?>
  70. <p><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
  71. $attachment_size = apply_filters( 'twentyten_attachment_size', 900 );
  72. echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height.
  73. ?></a></p>
  74. <?php previous_image_link( false ); ?>
  75. <?php next_image_link( false ); ?>
  76. <?php else : ?>
  77. <a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php echo basename( get_permalink() ); ?></a>
  78. <?php endif; ?>
  79. <?php if ( !empty( $post->post_excerpt ) ) the_excerpt(); ?>
  80. <?php the_content( __( 'Continue reading &rarr;', 'twentyten' ) ); ?>
  81. <?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
  82. <?php twentyten_posted_in(); ?>
  83. <?php edit_post_link( __( 'Edit', 'twentyten' ), ' ', '' ); ?>
  84. <?php comments_template(); ?>
  85. <?php endwhile; ?>
  86. <?php get_footer(); ?>