WordPress.org

Make WordPress Core

Ticket #22829: 22829.diff

File 22829.diff, 710 bytes (added by nacin, 5 years ago)
  • wp-includes/media.php

     
    836836
    837837        $k = $prev ? $k - 1 : $k + 1;
    838838
    839         if ( isset($attachments[$k]) )
    840                 echo wp_get_attachment_link($attachments[$k]->ID, $size, true, false, $text);
     839        $output = $attachment_id = null;
     840        if ( isset($attachments[$k]) ) {
     841                $attachment_id = $attachments[ $k ]->ID;
     842                $output = wp_get_attachment_link( $attachment_id, $size, true, false, $text );
     843        }
     844
     845        $adjacent = $prev ? 'previous' : 'next';
     846        echo apply_filters( "{$adjacent}_image_link", $output, $attachment_id, $size, $text, $attachments );
    841847}
    842848
    843849/**