[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentyeleven/ -> image.php (source)

   1  <?php
   2  /**
   3   * Template for displaying image attachments
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Eleven
   7   * @since Twenty Eleven 1.0
   8   */
   9  
  10  get_header(); ?>
  11  
  12          <div id="primary" class="image-attachment">
  13              <div id="content" role="main">
  14  
  15              <?php
  16              while ( have_posts() ) :
  17                  the_post();
  18                  ?>
  19  
  20                  <nav id="nav-single">
  21                      <h3 class="assistive-text"><?php _e( 'Image navigation', 'twentyeleven' ); ?></h3>
  22                      <span class="nav-previous"><?php previous_image_link( false, __( '&larr; Previous', 'twentyeleven' ) ); ?></span>
  23                      <span class="nav-next"><?php next_image_link( false, __( 'Next &rarr;', 'twentyeleven' ) ); ?></span>
  24                  </nav><!-- #nav-single -->
  25  
  26                      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  27                          <header class="entry-header">
  28                              <h1 class="entry-title"><?php the_title(); ?></h1>
  29  
  30                              <div class="entry-meta">
  31                                  <?php
  32                                      $metadata = wp_get_attachment_metadata();
  33                                      printf(
  34                                          /* translators: 1: Time, 2: Date, 3: Image permalink, 4: Image width, 5: Image height, 6: Parent permalink, 7: Parent post title, 8: Parent post title. */
  35                                          __( '<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="Go to %7$s" rel="gallery">%8$s</a>', 'twentyeleven' ),
  36                                          esc_attr( get_the_time() ),
  37                                          get_the_date(),
  38                                          esc_url( wp_get_attachment_url() ),
  39                                          $metadata['width'],
  40                                          $metadata['height'],
  41                                          esc_url( get_permalink( $post->post_parent ) ),
  42                                          esc_attr( strip_tags( get_the_title( $post->post_parent ) ) ),
  43                                          get_the_title( $post->post_parent )
  44                                      );
  45                                  ?>
  46                                  <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
  47                              </div><!-- .entry-meta -->
  48  
  49                          </header><!-- .entry-header -->
  50  
  51                          <div class="entry-content">
  52  
  53                              <div class="entry-attachment">
  54                                  <div class="attachment">
  55                  <?php
  56                  /*
  57                  * 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,
  58                  * 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
  59                  */
  60                  $attachments = array_values(
  61                      get_children(
  62                          array(
  63                              'post_parent'    => $post->post_parent,
  64                              'post_status'    => 'inherit',
  65                              'post_type'      => 'attachment',
  66                              'post_mime_type' => 'image',
  67                              'order'          => 'ASC',
  68                              'orderby'        => 'menu_order ID',
  69                          )
  70                      )
  71                  );
  72                  foreach ( $attachments as $k => $attachment ) {
  73                      if ( $attachment->ID === $post->ID ) {
  74                          break;
  75                      }
  76                  }
  77  
  78                  // If there is more than 1 attachment in a gallery...
  79                  if ( count( $attachments ) > 1 ) {
  80                      ++$k;
  81                      if ( isset( $attachments[ $k ] ) ) {
  82                          // ...get the URL of the next image attachment.
  83                          $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  84                      } else {
  85                          // ...or get the URL of the first image attachment.
  86                          $next_attachment_url = get_attachment_link( $attachments[0]->ID );
  87                      }
  88                  } else {
  89                      // Or, if there's only 1 image, get the URL of the image.
  90                      $next_attachment_url = wp_get_attachment_url();
  91                  }
  92                  ?>
  93                                      <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment">
  94                                          <?php
  95                                          /**
  96                                           * Filters the Twenty Eleven default attachment size.
  97                                           *
  98                                           * @since Twenty Eleven 1.0
  99                                           *
 100                                           * @param int The height and width attachment size dimensions in pixels. Default 848.
 101                                           */
 102                                          $attachment_size = apply_filters( 'twentyeleven_attachment_size', 848 );
 103                                          // Filterable image width with 1024px limit for image height.
 104                                          echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) );
 105                                          ?>
 106                                      </a>
 107  
 108                                      <?php if ( ! empty( $post->post_excerpt ) ) : ?>
 109                                      <div class="entry-caption">
 110                                          <?php the_excerpt(); ?>
 111                                      </div>
 112                                      <?php endif; ?>
 113                                  </div><!-- .attachment -->
 114  
 115                              </div><!-- .entry-attachment -->
 116  
 117                              <div class="entry-description">
 118                                  <?php the_content(); ?>
 119                                  <?php
 120                                  wp_link_pages(
 121                                      array(
 122                                          'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>',
 123                                          'after'  => '</div>',
 124                                      )
 125                                  );
 126                                  ?>
 127                              </div><!-- .entry-description -->
 128  
 129                          </div><!-- .entry-content -->
 130  
 131                      </article><!-- #post-<?php the_ID(); ?> -->
 132  
 133                      <?php comments_template(); ?>
 134  
 135                  <?php endwhile; // End of the loop. ?>
 136  
 137              </div><!-- #content -->
 138          </div><!-- #primary -->
 139  
 140  <?php get_footer(); ?>


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref