Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 25008)
+++ wp-includes/rewrite.php	(working copy)
@@ -297,6 +297,25 @@
 			return $id;
 	}
 
+	// Check if we are working with an image file 
+	$test_url = parse_url( $url );
+	if ( in_array( $test_url['scheme'], array( 'http', 'https' ) ) && preg_match( "/(?:png|jpg|gif)/ui", $test_url['path'], $matches ) ) {
+		global $wpdb;
+
+		$upload_dir = wp_upload_dir();
+
+		// Get the path or the original size image by slicing the widthxheight off the end and adding the extension back
+		$search_url = preg_replace( '/-\d+x\d+(\.(?:png|jpg|gif))$/i', '.' . $matches[0], $url );
+
+		// Get the path to search postmeta for
+		$search_url = explode( $upload_dir['baseurl'] . '/', $search_url );
+
+		$post_id = (int)$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_value LIKE %s", $search_url[1] ) );
+
+		if ( $post_id )
+			return $post_id;
+	}
+
 	// Check to see if we are using rewrite rules
 	$rewrite = $wp_rewrite->wp_rewrite_rules();
 
