PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/attachment.php

https://github.com/fprestes/Conde-WordPress-Theme
PHP | 76 lines | 58 code | 6 blank | 12 comment | 9 complexity | 7e93c44c41a4570b1f3c0ea6723156b5 MD5 | raw file
  1. <?php
  2. /**
  3. * The template for displaying attachments.
  4. *
  5. * @package WordPress
  6. * @subpackage Foursquare Two
  7. * @since Foursquare Two 1.0
  8. */
  9. get_header(); ?>
  10. <div class="row">
  11. <section id="blog" class="span7">
  12. <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  13. <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">
  14. <?php
  15. /* translators: %s - title of parent post */
  16. printf( __( '<span>ÂŤ</span> %s', 'twentyten' ), get_the_title( $post->post_parent ) );
  17. ?>
  18. </a></p>
  19. <h1><?php the_title(); ?></h1>
  20. <?php
  21. printf( __('Published %2$s', 'twentyten'),
  22. 'meta-prep meta-prep-entry-date',
  23. sprintf( '<abbr title="%1$s">%2$s</abbr>',
  24. esc_attr( get_the_time() ),
  25. get_the_date()
  26. ));
  27. if ( wp_attachment_is_image() ) {
  28. echo ' | ';
  29. $metadata = wp_get_attachment_metadata();
  30. printf( __( 'Full size: %s pixels', 'twentyten'),
  31. sprintf( '<a href="%1$s" title="%2$s">%3$s &times; %4$s</a>',
  32. wp_get_attachment_url(),
  33. esc_attr( __('Link to full-size image', 'twentyten') ),
  34. $metadata['width'],
  35. $metadata['height']));
  36. }
  37. ?>
  38. <?php // .entry-meta ?>
  39. <?php if ( wp_attachment_is_image() ) :
  40. $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' ) ) );
  41. foreach ( $attachments as $k => $attachment ) {
  42. if ( $attachment->ID == $post->ID )
  43. break;
  44. }
  45. $k++;
  46. // If there is more than 1 image attachment in a gallery
  47. if ( count( $attachments ) > 1 ) {
  48. if ( isset( $attachments[ $k ] ) )
  49. // get the URL of the next image attachment
  50. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  51. else
  52. // or get the URL of the first image attachment
  53. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID ); }
  54. else {
  55. // or, if there's only 1 image attachment, get the URL of the image
  56. $next_attachment_url = wp_get_attachment_url();
  57. }
  58. ?>
  59. <p><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment">
  60. <?php
  61. $attachment_size = apply_filters( 'twentyten_attachment_size', 900 );
  62. echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height.
  63. ?>
  64. </a></p>
  65. </section><!--end blog-->
  66. <?php include ('sidebar-blog.php'); ?>
  67. <?php comments_template( '', true ); ?>
  68. </div><!--end row-->
  69. <?php include ('sidebar-footer.php'); ?>
  70. <?php get_footer(); ?>