The get_next_image_link() WordPress PHP function retrieves the next image link that shares the same post parent.
Usage
get_next_image_link( $size, $text )
Example:
Input:
echo get_next_image_link('medium', 'Next Image');
Output:
A medium-sized image link with the text “Next Image.”
Parameters
$size
(string|int) Optional: Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Default is ‘thumbnail’.$text
(string|false) Optional: Link text. Default is false.
More information
See WordPress Developer Resources: get_next_image_link()
Examples
Display a link to the next image using the default ‘thumbnail’ size
Explanation: This code will display the link to the next image with the default ‘thumbnail’ size.
echo get_next_image_link();
Display a link to the next image with a custom size
Explanation: This code will display the link to the next image with a custom size of 200×200 pixels.
echo get_next_image_link(array(200, 200));
Display a link to the next image with a registered size
Explanation: This code will display the link to the next image with the registered ‘medium’ size.
echo get_next_image_link('medium');
Display a link to the next image with custom text
Explanation: This code will display the link to the next image with the custom text “Click for Next Image”.
echo get_next_image_link('thumbnail', 'Click for Next Image');
Display a link to the next image with custom size and text
Explanation: This code will display the link to the next image with a custom size of 300×300 pixels and the custom text “View Next Image”.
echo get_next_image_link(array(300, 300), 'View Next Image');