Changeset 43571 for trunk/src/wp-content/themes/twentytwelve/image.php
- Timestamp:
- 08/17/2018 01:50:26 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwelve/image.php
r42343 r43571 18 18 while ( have_posts() ) : 19 19 the_post(); 20 ?>20 ?> 21 21 22 22 <article id="post-<?php the_ID(); ?>" <?php post_class( 'image-attachment' ); ?>> … … 52 52 <div class="entry-attachment"> 53 53 <div class="attachment"> 54 <?php55 /*56 57 58 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;74 }54 <?php 55 /* 56 * 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, 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 58 */ 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; 74 } 75 75 endforeach; 76 76 77 // If there is more than 1 attachment in a gallery78 if ( count( $attachments ) > 1 ) :79 $k++;80 if ( isset( $attachments[ $k ] ) ) :81 // get the URL of the next image attachment82 $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );83 else :84 // or get the URL of the first image attachment85 $next_attachment_url = get_attachment_link( $attachments[0]->ID );86 endif;77 // If there is more than 1 attachment in a gallery 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 : 84 // or get the URL of the first image attachment 85 $next_attachment_url = get_attachment_link( $attachments[0]->ID ); 86 endif; 87 87 else : 88 88 // or, if there's only 1 image, get the URL of the image … … 104 104 $attachment_size = apply_filters( 'twentytwelve_attachment_size', array( 960, 960 ) ); 105 105 echo wp_get_attachment_image( $post->ID, $attachment_size ); 106 ?>106 ?> 107 107 </a> 108 108 … … 125 125 ) 126 126 ); 127 ?>127 ?> 128 128 </div><!-- .entry-description --> 129 129
Note: See TracChangeset
for help on using the changeset viewer.