diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index 7b99f95..83b6979 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -822,7 +822,7 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
 
 		// Generate 'srcset' and 'sizes' if not already present.
 		if ( empty( $attr['srcset'] ) ) {
-			$image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
+			$image_meta = wp_get_attachment_metadata( $attachment_id );
 
 			if ( is_array( $image_meta ) ) {
 				$size_array = array( absint( $width ), absint( $height ) );
@@ -951,7 +951,7 @@ function wp_get_attachment_image_srcset( $attachment_id, $size = 'medium', $imag
 	}
 
 	if ( ! is_array( $image_meta ) ) {
-		$image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
+		$image_meta = wp_get_attachment_metadata( $attachment_id );
 	}
 
 	$image_src = $image[0];
@@ -1166,7 +1166,7 @@ function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $image
 	}
 
 	if ( ! is_array( $image_meta ) ) {
-		$image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
+		$image_meta = wp_get_attachment_metadata( $attachment_id );
 	}
 
 	$image_src = $image[0];
@@ -1199,7 +1199,7 @@ function wp_calculate_image_sizes( $size, $image_src = null, $image_meta = null,
 		$width = absint( $size[0] );
 	} elseif ( is_string( $size ) ) {
 		if ( ! $image_meta && $attachment_id ) {
-			$image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
+			$image_meta = wp_get_attachment_metadata( $attachment_id );
 		}
 
 		if ( is_array( $image_meta ) ) {
@@ -1274,7 +1274,7 @@ function wp_make_content_images_responsive( $content ) {
 	}
 
 	foreach ( $selected_images as $image => $attachment_id ) {
-		$image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
+		$image_meta = wp_get_attachment_metadata( $attachment_id );
 		$content = str_replace( $image, wp_image_add_srcset_and_sizes( $image, $image_meta, $attachment_id ), $content );
 	}
 
diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php
index 5399f85..56cd19c 100644
--- a/tests/phpunit/tests/media.php
+++ b/tests/phpunit/tests/media.php
@@ -1476,4 +1476,34 @@ EOF;
 
 		$this->assertSame( $expected, $actual );
 	}
+
+	/**
+	 * Tests if wp_get_attachment_image() uses wp_get_attachment_metadata().
+	 *
+	 * In this way, the meta data can be filtered using the filter
+	 * `wp_get_attachment_metadata`.
+	 *
+	 * The test checks if the image size that is added in the filter is
+	 * used in the output of `wp_get_attachment_image()`.
+	 *
+	 * @ticket 36246
+	 */
+	function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() {
+	  add_filter( 'wp_get_attachment_metadata', array($this, 'filter_test_wp_get_attachment_image_should_use_wp_get_attachment_metadata'), 10, 2 );
+
+		$actual = wp_get_attachment_image( self::$large_id, 'testsize' );
+		$expeced = '<img width="999" height="999" src="http://example.org/wp-content/uploads/2016/03/test-image-testsize-999x999.png" class="attachment-testsize size-testsize" alt="test-image-large.png" />';
+
+		remove_filter( 'wp_get_attachment_metadata', array($this, 'filter_test_wp_get_attachment_image_should_use_wp_get_attachment_metadata') );
+	}
+
+	function filter_test_wp_get_attachment_image_should_use_wp_get_attachment_metadata($data, $attachment_id) {
+		$data['sizes']['testsize'] = array(
+      'file' => 'test-image-testsize-999x999.png',
+      'width' => 999,
+      'height' => 999,
+      'mime-type' => 'image/png',
+    );
+		return $data;
+	}
 }
