WordPress.org

Make WordPress Core

Ticket #13052: media.diff

File media.diff, 927 bytes (added by iandstewart, 8 years ago)
  • media.php

     
    881881}
    882882
    883883/**
     884 * Return the URL of the next adjacent image in a gallery or the URL of the parent post
     885 */
     886function get_next_image_url() {
     887        global $post;
     888        $post = get_post($post);
     889        $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') ));
     890
     891        foreach ( $attachments as $k => $attachment )
     892                if ( $attachment->ID == $post->ID )
     893                        break;
     894
     895                $k = $k + 1;
     896
     897                if ( isset($attachments[$k]) ) {
     898                        return get_attachment_link($attachments[$k]->ID);
     899                } else {
     900                        return get_permalink($post->post_parent);
     901                }
     902}
     903
     904/**
    884905 * Retrieve taxonomies attached to the attachment.
    885906 *
    886907 * @since 2.5.0