Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 44334)
+++ src/wp-includes/media.php	(working copy)
@@ -2755,12 +2755,27 @@
 add_shortcode( 'video', 'wp_video_shortcode' );
 
 /**
+ * Returns previous image link that has the same post parent.
+ *
+ * @since 5.1.0
+ *
+ * @see get_adjacent_image_link()
+ *
+ * @param string|array $size Optional. Image size. Accepts any valid image size, an array of width and
+ *                           height values in pixels (in that order), 0, or 'none'. 0 or 'none' will
+ *                           default to 'post_title' or `$text`. Default 'thumbnail'.
+ * @param string       $text Optional. Link text. Default false.
+ * @return string Markup for previous image link.
+ */
+function get_previous_image_link( $size = 'thumbnail', $text = false ) {
+	return get_adjacent_image_link( true, $size, $text );
+}
+
+/**
  * Displays previous image link that has the same post parent.
  *
  * @since 2.5.0
  *
- * @see adjacent_image_link()
- *
  * @param string|array $size Optional. Image size. Accepts any valid image size, an array of width and
  *                           height values in pixels (in that order), 0, or 'none'. 0 or 'none' will
  *                           default to 'post_title' or `$text`. Default 'thumbnail'.
@@ -2771,12 +2786,27 @@
 }
 
 /**
+ * Returns next image link that has the same post parent.
+ *
+ * @since 5.1.0
+ *
+ * @see get_adjacent_image_link()
+ *
+ * @param string|array $size Optional. Image size. Accepts any valid image size, an array of width and
+ *                           height values in pixels (in that order), 0, or 'none'. 0 or 'none' will
+ *                           default to 'post_title' or `$text`. Default 'thumbnail'.
+ * @param string       $text Optional. Link text. Default false.
+ * @return string Markup for next image link.
+ */
+function get_next_image_link( $size = 'thumbnail', $text = false ) {
+	return get_adjacent_image_link( false, $size, $text );
+}
+
+/**
  * Displays next image link that has the same post parent.
  *
  * @since 2.5.0
  *
- * @see adjacent_image_link()
- *
  * @param string|array $size Optional. Image size. Accepts any valid image size, an array of width and
  *                           height values in pixels (in that order), 0, or 'none'. 0 or 'none' will
  *                           default to 'post_title' or `$text`. Default 'thumbnail'.
@@ -2783,22 +2813,23 @@
  * @param string       $text Optional. Link text. Default false.
  */
 function next_image_link( $size = 'thumbnail', $text = false ) {
-	adjacent_image_link( false, $size, $text );
+	echo get_next_image_link( $size, $text );
 }
 
 /**
- * Displays next or previous image link that has the same post parent.
+ * Returns next or previous image link that has the same post parent.
  *
  * Retrieves the current attachment object from the $post global.
  *
- * @since 2.5.0
+ * @since 5.1.0
  *
  * @param bool         $prev Optional. Whether to display the next (false) or previous (true) link. Default true.
  * @param string|array $size Optional. Image size. Accepts any valid image size, or an array of width and height
  *                           values in pixels (in that order). Default 'thumbnail'.
  * @param bool         $text Optional. Link text. Default false.
+ * @return string Markup for image link.
  */
-function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false ) {
+function get_adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false ) {
 	$post        = get_post();
 	$attachments = array_values(
 		get_children(
@@ -2846,10 +2877,26 @@
 	 * @param string $size          Image size.
 	 * @param string $text          Link text.
 	 */
-	echo apply_filters( "{$adjacent}_image_link", $output, $attachment_id, $size, $text );
+	return apply_filters( "{$adjacent}_image_link", $output, $attachment_id, $size, $text );
 }
 
 /**
+ * Displays next or previous image link that has the same post parent.
+ *
+ * Retrieves the current attachment object from the $post global.
+ *
+ * @since 2.5.0
+ *
+ * @param bool         $prev Optional. Whether to display the next (false) or previous (true) link. Default true.
+ * @param string|array $size Optional. Image size. Accepts any valid image size, or an array of width and height
+ *                           values in pixels (in that order). Default 'thumbnail'.
+ * @param bool         $text Optional. Link text. Default false.
+ */
+function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false ) {
+	echo get_adjacent_image_link( $prev, $size, $text );
+}
+
+/**
  * Retrieves taxonomies attached to given the attachment.
  *
  * @since 2.5.0
