WordPress.org

Make WordPress Core

Ticket #22829: 22829.2.diff

File 22829.2.diff, 737 bytes (added by nacin, 2 years ago)
  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index 8d99359..8235d46 100644
    function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) { 
    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 ); 
    841847} 
    842848 
    843849/**