Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 35953)
+++ src/wp-includes/media.php	(working copy)
@@ -878,6 +878,26 @@
 }
 
 /**
+ * Get the attachment path relative to the upload directory.
+ *
+ * @since 4.4.1
+ * @access private
+ *
+ * @param string $file Attachment file name.
+ * @return string Attachment path relative to the upload directory.
+ */
+function _wp_get_attachment_relative_path( $file ) {
+	$dirname = dirname( $file );
+
+	if ( false !== strpos( $dirname, 'wp-content/uploads/' ) ) {
+		// Get the directory name relative to the upload directory (back compat for pre-2.7 uploads)
+		$dirname = substr( $dirname, strpos( $dirname, 'wp-content/uploads/' ) + 19 );
+	}
+
+	return $dirname;
+}
+
+/**
  * Caches and returns the base URL of the uploads directory.
  *
  * @since 4.4.0
@@ -1006,7 +1026,7 @@
 
 	// Uploads are (or have been) in year/month sub-directories.
 	if ( $image_basename !== $image_meta['file'] ) {
-		$dirname = dirname( $image_meta['file'] );
+		$dirname = _wp_get_attachment_relative_path( $image_meta['file'] );
 
 		if ( $dirname !== '.' ) {
 			$image_baseurl = trailingslashit( $image_baseurl ) . $dirname;
Index: src/wp-includes/post.php
===================================================================
--- src/wp-includes/post.php	(revision 35953)
+++ src/wp-includes/post.php	(working copy)
@@ -4879,7 +4879,8 @@
 				// Replace file location with url location.
 				$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file);
 			} elseif ( false !== strpos($file, 'wp-content/uploads') ) {
-				$url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
+				// Get the directory name relative to the basedir (back compat for pre-2.7 uploads)
+				$url = $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file );
 			} else {
 				// It's a newly-uploaded file, therefore $file is relative to the basedir.
 				$url = $uploads['baseurl'] . "/$file";
Index: tests/phpunit/tests/media.php
===================================================================
--- tests/phpunit/tests/media.php	(revision 35953)
+++ tests/phpunit/tests/media.php	(working copy)
@@ -866,6 +866,48 @@
 	}
 
 	/**
+	 * @ticket 35106
+	 */
+	function test_wp_calculate_image_srcset_with_absolute_path_in_meta() {
+		global $_wp_additional_image_sizes;
+
+		$year_month = date('Y/m');
+		$image_meta = wp_get_attachment_metadata( self::$large_id );
+		$uploads_dir_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
+
+		// Set up test cases for all expected size names.
+		$intermediates = array( 'medium', 'medium_large', 'large', 'full' );
+
+		// Add any soft crop intermediate sizes.
+		foreach ( $_wp_additional_image_sizes as $name => $additional_size ) {
+			if ( ! $_wp_additional_image_sizes[$name]['crop'] || 0 === $_wp_additional_image_sizes[$name]['height'] ) {
+				$intermediates[] = $name;
+			}
+		}
+
+		$expected = '';
+
+		foreach( $image_meta['sizes'] as $name => $size ) {
+			// Whitelist the sizes that should be included so we pick up 'medium_large' in 4.4.
+			if ( in_array( $name, $intermediates ) ) {
+				$expected .= $uploads_dir_url . $year_month . '/' . $size['file'] . ' ' . $size['width'] . 'w, ';
+			}
+		}
+
+		// Add the full size width at the end.
+		$expected .= $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] .'w';
+
+		// Prepend an absolute path to simulate a pre-2.7 upload
+		$image_meta['file'] = 'H:\home\wordpress\trunk/wp-content/uploads/' . $image_meta['file'];
+
+		foreach ( $intermediates as $int ) {
+			$image_url = wp_get_attachment_image_url( self::$large_id, $int );
+			$size_array = $this->_get_image_size_array_from_name( $int );
+ 			$this->assertSame( $expected, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) );
+ 		}
+	}
+
+	/**
 	 * @ticket 33641
 	 */
 	function test_wp_calculate_image_srcset_false() {
