Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(Revision 36846)
+++ wp-includes/functions.php	(Arbeitskopie)
@@ -1846,15 +1846,16 @@
  * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
  * @param bool   $create_dir Optional. Whether to check and create the uploads directory. Default true (backwards compatible).
  * @param bool   $refresh_cache Optional. Whether to refresh the cache. Default false.
+ * @param string $scheme Optional. Scheme to give the uploads url context. See set_url_scheme().
  * @return array See above for description.
  */
-function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
+function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false, $scheme = null ) {
 	static $cache = array();
 
-	$key = sprintf( '%d-%s', get_current_blog_id(), (string) $time );
+	$key = sprintf( '%d-%s-%s', get_current_blog_id(), (string) $time, (string) $scheme );
 
 	if ( $refresh_cache || empty( $cache[ $key ] ) ) {
-		$cache[ $key ] = _wp_upload_dir( $time );
+		$cache[ $key ] = _wp_upload_dir( $time, $scheme );
 	}
 
 	/**
@@ -1900,9 +1901,10 @@
  * @access private
  *
  * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
+ * @param string $scheme Optional. Scheme to give the uploads url context. See set_url_scheme().
  * @return array See wp_upload_dir()
  */
-function _wp_upload_dir( $time = null ) {
+function _wp_upload_dir( $time = null, $scheme = null ) {
 	$siteurl = get_option( 'siteurl' );
 	$upload_path = trim( get_option( 'upload_path' ) );
 
@@ -1974,6 +1976,8 @@
 			$url = trailingslashit( $siteurl ) . 'files';
 		}
 	}
+	
+	$url = set_url_scheme( $url, $scheme );
 
 	$basedir = $dir;
 	$baseurl = $url;
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(Revision 36846)
+++ wp-includes/media.php	(Arbeitskopie)
@@ -333,6 +333,20 @@
 
 	list( $img_src, $width, $height ) = image_downsize($id, $size);
 	$hwstring = image_hwstring($width, $height);
+	
+	// Determine the scheme of the image source URL
+	if ( $url = get_option( 'upload_url_path' ) ) {
+		$scheme = parse_url( $url, PHP_URL_SCHEME );
+	} else {
+		/*
+		 * The upload_url_path option is not set. Therefore, use the scheme
+		 * of the WP_CONTENT_URL constant. If it is not set by the user, it
+		 * defaults to the siteurl option.
+		 */
+		$scheme = parse_url( WP_CONTENT_URL, PHP_URL_SCHEME );
+	}
+	
+	$img_src = set_url_scheme( $img_src, $scheme );
 
 	$title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';
 
