Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 19621)
+++ wp-admin/includes/media.php	(working copy)
@@ -586,9 +586,10 @@
  * @param string $file The URL of the image to download
  * @param int $post_id The post ID the media is to be associated with
  * @param string $desc Optional. Description of the image
- * @return string|WP_Error Populated HTML img tag on success
+ * @param string $html Optional. Return html markup if true, attach id if false
+ * @return string|int|WP_Error Populated HTML img tag or attachment id on success
  */
-function media_sideload_image($file, $post_id, $desc = null) {
+function media_sideload_image($file, $post_id, $desc = null, $html = true) {
 	if ( ! empty($file) ) {
 		// Download file to temp location
 		$tmp = download_url( $file );
@@ -620,7 +621,11 @@
 	if ( ! empty($src) ) {
 		$alt = isset($desc) ? esc_attr($desc) : '';
 		$html = "<img src='$src' alt='$alt' />";
-		return $html;
+		if ( $html ) {
+			return $html;
+		} else {
+			return $id;
+		}
 	}
 }
 
