The scheme site property might be ignored when creating media URLs with Media.AlwaysIncludeServerUrl setting set to true. For example, changing the site node scheme property to HTTPS does change the internal hyperlink scheme but not the Sitecore media link scheme. The Media Provider does not obey the scheme setting from the site configuration file. It just sends back the same scheme that was sent on the request.
To resolve the issue, download and install the appropriate patch available on this page: https://github.com/SitecoreSupport/Sitecore.Support.170025/releases
To get a solution for other XP releases, contact Sitecore Support.