Index: src/wp-admin/includes/image.php
===================================================================
--- src/wp-admin/includes/image.php	(revision 39560)
+++ src/wp-admin/includes/image.php	(working copy)
@@ -221,15 +221,29 @@
 		$fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata );
 
 		$sizes = array();
+		$_wp_additional_image_sizes = wp_get_additional_image_sizes();
 
 		foreach ( $fallback_sizes as $s ) {
-			$sizes[ $s ]['width']  = get_option( "{$s}_size_w" );
-			$sizes[ $s ]['height'] = get_option( "{$s}_size_h" );
+			if ( isset( $_wp_additional_image_sizes[ $s ]['width'] ) ) {
+				$sizes[ $s ]['width'] = intval( $_wp_additional_image_sizes[ $s ]['width'] );
+			} else {
+				$sizes[ $s ]['width'] = get_option( "{$s}_size_w" );
+			}
 
-			// Force thumbnails to be soft crops.
-			if ( ! 'thumbnail' === $s ) {
-				$sizes[ $s ]['crop'] = get_option( "{$s}_crop" );
+			if ( isset( $_wp_additional_image_sizes[ $s ]['height'] ) ) {
+				$sizes[ $s ]['height'] = intval( $_wp_additional_image_sizes[ $s ]['height'] );
+			} else {
+				$sizes[ $s ]['height'] = get_option( "{$s}_size_h" );
 			}
+
+			if ( isset( $_wp_additional_image_sizes[ $s ]['crop'] ) ) {
+				$sizes[ $s ]['crop'] = $_wp_additional_image_sizes[ $s ]['crop'];
+			} else {
+				// Force thumbnails to be soft crops.
+				if ( ! 'thumbnail' === $s ) {
+					$sizes[ $s ]['crop'] = get_option( "{$s}_crop" );
+				}
+			}
 		}
 
 		// Only load PDFs in an image editor if we're processing sizes.
Index: tests/phpunit/tests/image/functions.php
===================================================================
--- tests/phpunit/tests/image/functions.php	(revision 39560)
+++ tests/phpunit/tests/image/functions.php	(working copy)
@@ -404,4 +404,70 @@
 
 		unlink( $test_file );
 	}
+
+	/**
+	 * @ticket 39231
+	 */
+	public function test_fallback_intermediate_image_sizes() {
+		if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) {
+			$this->markTestSkipped( 'Rendering PDFs is not supported on this system.' );
+		}
+
+		$orig_file = DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf';
+		$test_file = '/tmp/wordpress-gsoc-flyer.pdf';
+		copy( $orig_file, $test_file );
+
+		$attachment_id = $this->factory->attachment->create_object( $test_file, 0, array(
+			'post_mime_type' => 'application/pdf',
+		) );
+
+		$this->assertNotEmpty( $attachment_id );
+
+		add_image_size( 'test-size', 100, 100 );
+		add_filter( 'fallback_intermediate_image_sizes', array( $this, 'filter_fallback_intermediate_image_sizes' ), 10, 2 );
+
+		$expected = array(
+			'sizes' => array(
+				'thumbnail' => array(
+					'file'      => "wordpress-gsoc-flyer-116x150.jpg",
+					'width'     => 116,
+					'height'    => 150,
+					'mime-type' => "image/jpeg",
+				),
+				'medium'    => array(
+					'file'      => "wordpress-gsoc-flyer-232x300.jpg",
+					'width'     => 232,
+					'height'    => 300,
+					'mime-type' => "image/jpeg",
+				),
+				'test-size'     => array(
+					'file'      => "wordpress-gsoc-flyer-77x100.jpg",
+					'width'     => 77,
+					'height'    => 100,
+					'mime-type' => "image/jpeg",
+				),
+				'full'      => array(
+					'file'      => "wordpress-gsoc-flyer.jpg",
+					'width'     => 1088,
+					'height'    => 1408,
+					'mime-type' => "image/jpeg",
+				),
+			),
+		);
+
+		$metadata = wp_generate_attachment_metadata( $attachment_id, $test_file );
+		$this->assertSame( $expected, $metadata );
+
+		remove_image_size( 'test-size' );
+		remove_filter( 'fallback_intermediate_image_sizes', array( $this, 'filter_fallback_intermediate_image_sizes' ), 10 );
+
+		unlink( $test_file );
+	}
+
+	function filter_fallback_intermediate_image_sizes( $fallback_sizes, $metadata ) {
+		if ( false !== ( $idx = array_search( 'large', $fallback_sizes, true ) ) ) {
+			$fallback_sizes[ $idx ] = 'test-size';
+		}
+		return $fallback_sizes;
+	}
 }
