PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/twentyten/attachment.php

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