diff --git a/src/wp-admin/includes/deprecated.php b/src/wp-admin/includes/deprecated.php
index e65fe5a79c..e49d8acb10 100644
--- a/src/wp-admin/includes/deprecated.php
+++ b/src/wp-admin/includes/deprecated.php
@@ -1514,3 +1514,33 @@ function options_permalink_add_js() {
 	</script>
 	<?php
 }
+
+
+/**
+ * Retrieve thumbnail for an attachment.
+ *
+ * @since 2.1.0
+ * @deprecated 5.2 Use wp_get_attachment_image_file( $attachment_id, $size = 'thumbnail' )
+ *
+ * @param int $post_id Optional. Attachment ID. Default 0.
+ * @return string|false False on failure. Thumbnail file path on success.
+ */
+function wp_get_attachment_thumb_file( $post_id = 0 ) {
+	_deprecated_function( __FUNCTION__, '5.2' );
+
+	$file = wp_get_attachment_image_file( $post_id );
+
+	if ( $file ) {
+		/**
+		 * Filters the attachment thumbnail file path.
+		 *
+		 * @since 2.1.0
+		 * @deprecated 5.2 Use filter wp_get_attachment_image_file( $file, $attachment_id, $size )
+		 *
+		 * @param string $thumbfile File path to the attachment thumbnail.
+		 * @param int    $post_id   Attachment ID.
+		 */
+		return apply_filters( 'wp_get_attachment_thumb_file', $file, $post->ID );
+	}
+	return false;
+}
diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index 019086c3b8..578e99713d 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -945,6 +945,56 @@ function wp_get_attachment_image_url( $attachment_id, $size = 'thumbnail', $icon
 	return isset( $image['0'] ) ? $image['0'] : false;
 }
 
+/**
+ * Get the size path of an image attachment.
+ *
+ * @since 5.2
+ *
+ * @param int          $attachment_id Attachment ID.
+ * @param string|array $size          Optional. Image size to retrieve. Accepts any valid image size, or an array
+ *                                    of width and height values. Default 'thumbnail'
+ *
+ * @return string|null Attachment path or null if no image is available.
+ */
+function wp_get_attachment_image_file( $attachment_id, $size = 'thumbnail' ) {
+
+	if ( 0 === (int) $attachment_id ) {
+		return null;
+	}
+
+	$attachment_metadata = wp_get_attachment_metadata( $attachment_id );
+
+	if ( ! $attachment_metadata ) {
+		return null;
+	}
+
+	$file_name = isset( $attachment_metadata['sizes'][ $size ]['file'] ) ? $attachment_metadata['sizes'][ $size ]['file'] : false;
+
+	$file = dirname( $attachment_metadata['file'] ) . '/' . $file_name;
+
+	$file_path = _wp_get_attachment_relative_path( $file );
+
+	if ( empty( $file_path ) ) {
+		return null;
+	}
+
+	$wp_upload_dir = wp_upload_dir( null, null );
+
+	$path = $wp_upload_dir['basedir'] . '/' . trailingslashit( $file_path ) . $file_name;
+
+	/**
+	 * Filters the attachment image file path.
+	 *
+	 * @since 5.2
+	 *
+	 * @param string $path          File path to the image file.
+	 * @param int    $attachment_id Attachment ID.
+	 * @param string $size          Image size used to get the size.
+	 */
+	return apply_filters( 'wp_get_attachment_image_file', $path, $attachment_id, $size );
+}
+
+
 /**
  * Get the attachment path relative to the upload directory.
  *
diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index eb69ac727b..27873153ce 100644
--- a/src/wp-includes/post.php
+++ b/src/wp-includes/post.php
@@ -5685,39 +5685,6 @@ function wp_get_attachment_caption( $post_id = 0 ) {
 	return apply_filters( 'wp_get_attachment_caption', $caption, $post->ID );
 }
 
-/**
- * Retrieve thumbnail for an attachment.
- *
- * @since 2.1.0
- *
- * @param int $post_id Optional. Attachment ID. Default 0.
- * @return string|false False on failure. Thumbnail file path on success.
- */
-function wp_get_attachment_thumb_file( $post_id = 0 ) {
-	$post_id = (int) $post_id;
-	if ( ! $post = get_post( $post_id ) ) {
-		return false;
-	}
-	if ( ! is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) {
-		return false;
-	}
-
-	$file = get_attached_file( $post->ID );
-
-	if ( ! empty( $imagedata['thumb'] ) && ( $thumbfile = str_replace( wp_basename( $file ), $imagedata['thumb'], $file ) ) && file_exists( $thumbfile ) ) {
-		/**
-		 * Filters the attachment thumbnail file path.
-		 *
-		 * @since 2.1.0
-		 *
-		 * @param string $thumbfile File path to the attachment thumbnail.
-		 * @param int    $post_id   Attachment ID.
-		 */
-		return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
-	}
-	return false;
-}
-
 /**
  * Retrieve URL for an attachment thumbnail.
  *
diff --git a/tests/phpunit/tests/media/getImageAttachmentSize.php b/tests/phpunit/tests/media/getImageAttachmentSize.php
new file mode 100644
index 0000000000..37f2162f53
--- /dev/null
+++ b/tests/phpunit/tests/media/getImageAttachmentSize.php
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * @group media
+ */
+class Tests_Media_GetImageAttachmentSize extends WP_UnitTestCase {
+
+	/** @var array WP Upload Dir. */
+	protected $wp_upload_dir;
+
+	public function setUp() {
+		$this->wp_upload_dir = wp_upload_dir();
+
+		parent::setUp();
+	}
+
+	/**
+	 * Creating file.
+	 *
+	 * @param string $file_name Image file name.
+	 *
+	 * @return int Attachment ID.
+	 */
+	protected function upload_image( $file_name ) {
+		$post_id = self::factory()->post->create( [ 'post_author' => 1 ] );
+
+		\copy( DIR_TESTDATA . '/images/' . $file_name, $this->wp_upload_dir['path'] . '/' . $file_name );
+
+		$file = $this->wp_upload_dir['path'] . '/' . $file_name;
+
+		$wp_filetype = wp_check_filetype( basename( $file ), null );
+
+		$attachment_id = wp_insert_attachment(
+			[
+				'post_mime_type' => $wp_filetype['type'],
+				'post_status'    => 'inherit',
+				'post_title'     => preg_replace( '/\.[^.]+$/', '', basename( $file ) ),
+				'post_content'   => '',
+			],
+			$file,
+			$post_id
+		);
+
+		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $file );
+
+		wp_update_attachment_metadata( $attachment_id, $attachment_data, $post_id );
+
+		return $attachment_id;
+	}
+
+	public function test_get_attachment_image_size() {
+		$attachment_id = $this->upload_image( 'waffles.jpg' );
+
+		$file_size = wp_get_attachment_image_file( $attachment_id, 'medium' );
+
+		$this->assertContains( 'waffles-300x200.jpg', $file_size );
+	}
+
+	public function test_get_custom_attachment_image_size() {
+		add_image_size( 'custom', 400, 400, true );
+
+		$attachment_id = $this->upload_image( 'canola.jpg' );
+
+		$file_size = wp_get_attachment_image_file( $attachment_id, 'custom' );
+
+		$this->assertContains( 'canola-400x400.jpg', $file_size );
+	}
+}
