WordPress.org

Make WordPress Core

Changeset 7222


Ignore:
Timestamp:
03/11/08 00:09:14 (6 years ago)
Author:
matt
Message:

Better media attachment template. See #5911. Hat tip: andy.

Location:
trunk
Files:
1 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r7218 r7222  
    339339} 
    340340 
     341function previous_image_link() { 
     342    adjacent_image_link(true); 
     343} 
     344 
     345function next_image_link() { 
     346    adjacent_image_link(false); 
     347} 
     348 
     349function adjacent_image_link($prev = true) { 
     350    global $post; 
     351    $post = get_post($post); 
     352    $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\"")); 
     353 
     354    foreach ( $attachments as $k => $attachment ) 
     355        if ( $attachment->ID == $post->ID ) 
     356            break; 
     357 
     358    $k = $prev ? $k - 1 : $k + 1; 
     359 
     360    if ( isset($attachments[$k]) ) 
     361        echo get_the_attachment_link($attachments[$k]->ID, true, array(128, 96), true); 
     362} 
     363 
    341364?> 
Note: See TracChangeset for help on using the changeset viewer.