Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(Revision 36846)
+++ wp-includes/functions.php	(Arbeitskopie)
@@ -1846,9 +1846,10 @@
  * @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 upload 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 );
@@ -1856,6 +1857,9 @@
 	if ( $refresh_cache || empty( $cache[ $key ] ) ) {
 		$cache[ $key ] = _wp_upload_dir( $time );
 	}
+	
+	$uploads['url'] = set_url_scheme( $uploads['url'], $scheme );
+	$uploads['baseurl'] = set_url_scheme( $uploads['baseurl'], $scheme );
 
 	/**
 	 * Filter the uploads directory data.
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(Revision 36846)
+++ wp-includes/media.php	(Arbeitskopie)
@@ -333,6 +333,10 @@
 
 	list( $img_src, $width, $height ) = image_downsize($id, $size);
 	$hwstring = image_hwstring($width, $height);
+	
+	// Scheme of the image source URL should match frontend scheme
+	$scheme = parse_url( get_option( 'home' ), PHP_URL_SCHEME );
+	$img_src = set_url_scheme( $img_src, $scheme );
 
 	$title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';
 
