Changeset 42343 for trunk/src/wp-content/themes/twentyeleven/image.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyeleven/image.php
r31265 r42343 13 13 <div id="content" role="main"> 14 14 15 <?php while ( have_posts() ) : the_post(); ?> 15 <?php 16 while ( have_posts() ) : 17 the_post(); 18 ?> 16 19 17 20 <nav id="nav-single"> 18 21 <h3 class="assistive-text"><?php _e( 'Image navigation', 'twentyeleven' ); ?></h3> 19 <span class="nav-previous"><?php previous_image_link( false, __( '← Previous' 20 <span class="nav-next"><?php next_image_link( false, __( 'Next →' 22 <span class="nav-previous"><?php previous_image_link( false, __( '← Previous', 'twentyeleven' ) ); ?></span> 23 <span class="nav-next"><?php next_image_link( false, __( 'Next →', 'twentyeleven' ) ); ?></span> 21 24 </nav><!-- #nav-single --> 22 25 … … 28 31 <?php 29 32 $metadata = wp_get_attachment_metadata(); 30 printf( __( '<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 × %5$s</a> in <a href="%6$s" title="Return to %7$s" rel="gallery">%8$s</a>', 'twentyeleven' ), 33 printf( 34 __( '<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 × %5$s</a> in <a href="%6$s" title="Return to %7$s" rel="gallery">%8$s</a>', 'twentyeleven' ), 31 35 esc_attr( get_the_time() ), 32 36 get_the_date(), … … 53 57 * 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 54 58 */ 55 $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' ) ) ); 56 foreach ( $attachments as $k => $attachment ) { 57 if ( $attachment->ID == $post->ID ) 58 break; 59 $attachments = array_values( 60 get_children( 61 array( 62 'post_parent' => $post->post_parent, 63 'post_status' => 'inherit', 64 'post_type' => 'attachment', 65 'post_mime_type' => 'image', 66 'order' => 'ASC', 67 'orderby' => 'menu_order ID', 68 ) 69 ) 70 ); 71 foreach ( $attachments as $k => $attachment ) { 72 if ( $attachment->ID == $post->ID ) { 73 break; 59 74 } 75 } 60 76 61 77 // If there is more than 1 attachment in a gallery 62 if ( count( $attachments ) > 1 ) { 63 $k++; 64 if ( isset( $attachments[ $k ] ) ) 65 // get the URL of the next image attachment 66 $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 67 else 68 // or get the URL of the first image attachment 69 $next_attachment_url = get_attachment_link( $attachments[0]->ID ); 70 } else { 71 // or, if there's only 1 image, get the URL of the image 72 $next_attachment_url = wp_get_attachment_url(); 78 if ( count( $attachments ) > 1 ) { 79 $k++; 80 if ( isset( $attachments[ $k ] ) ) { 81 // get the URL of the next image attachment 82 $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 83 } else { // or get the URL of the first image attachment 84 $next_attachment_url = get_attachment_link( $attachments[0]->ID ); 73 85 } 86 } else { 87 // or, if there's only 1 image, get the URL of the image 88 $next_attachment_url = wp_get_attachment_url(); 89 } 74 90 ?> 75 <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php 76 /** 77 * Filter the Twenty Eleven default attachment size. 78 * 79 * @since Twenty Eleven 1.0 80 * 81 * @param int The height and width attachment size dimensions in pixels. Default 848. 82 */ 83 $attachment_size = apply_filters( 'twentyeleven_attachment_size', 848 ); 84 echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height. 85 ?></a> 91 <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"> 92 <?php 93 /** 94 * Filter the Twenty Eleven default attachment size. 95 * 96 * @since Twenty Eleven 1.0 97 * 98 * @param int The height and width attachment size dimensions in pixels. Default 848. 99 */ 100 $attachment_size = apply_filters( 'twentyeleven_attachment_size', 848 ); 101 echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height. 102 ?> 103 </a> 86 104 87 105 <?php if ( ! empty( $post->post_excerpt ) ) : ?> … … 96 114 <div class="entry-description"> 97 115 <?php the_content(); ?> 98 <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?> 116 <?php 117 wp_link_pages( 118 array( 119 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 120 'after' => '</div>', 121 ) 122 ); 123 ?> 99 124 </div><!-- .entry-description --> 100 125
Note: See TracChangeset
for help on using the changeset viewer.