Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 29725)
+++ src/wp-includes/media.php	(working copy)
@@ -607,16 +607,41 @@
 		}
 	}
 
-	if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) )
+	if ( is_array( $size ) || empty( $size ) || ! isset( $GLOBALS['_wp_additional_image_sizes'][ $size ] ) ) {
 		return false;
+	}
 
-	$data = $imagedata['sizes'][$size];
+	if ( empty( $imagedata['sizes'][ $size ] ) ) {
+		$file_path = get_attached_file( $post_id );
+		$editor    = wp_get_image_editor( $file_path );
+
+		if ( is_wp_error( $editor ) ) {
+			return false;
+		}
+
+		$meta          = wp_get_attachment_metadata( $post_id );
+		$size_meta     = $editor->multi_resize( array( $size => $GLOBALS['_wp_additional_image_sizes'][ $size ] ) );
+
+		if ( ! isset( $size_meta[ $size ] ) ) {
+			return false;
+		}
+
+		$meta['sizes'] = array_merge( $meta['sizes'], $size_meta );
+
+		wp_update_attachment_metadata( $post_id, $meta );
+
+		return $size_meta[ $size ];
+	}
+
+	$data = $imagedata['sizes'][ $size ];
+
 	// include the full filesystem path of the intermediate file
-	if ( empty($data['path']) && !empty($data['file']) ) {
-		$file_url = wp_get_attachment_url($post_id);
-		$data['path'] = path_join( dirname($imagedata['file']), $data['file'] );
-		$data['url'] = path_join( dirname($file_url), $data['file'] );
+	if ( empty( $data['path'] ) && ! empty( $data['file'] ) ) {
+		$file_url = wp_get_attachment_url( $post_id );
+		$data['path'] = path_join( dirname( $imagedata['file']), $data['file'] );
+		$data['url'] = path_join( dirname( $file_url), $data['file'] );
 	}
+
 	return $data;
 }
 
