WordPress.org

Make WordPress Core

Ticket #25449: 25449.3.diff

File 25449.3.diff, 2.6 KB (added by thomaswm, 3 years ago)

corrected version of 25449.2.diff

  • wp-includes/functions.php

     
    18461846 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
    18471847 * @param bool   $create_dir Optional. Whether to check and create the uploads directory. Default true (backwards compatible).
    18481848 * @param bool   $refresh_cache Optional. Whether to refresh the cache. Default false.
     1849 * @param string $scheme Optional. Scheme to give the uploads url context. See set_url_scheme().
    18491850 * @return array See above for description.
    18501851 */
    1851 function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
     1852function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false, $scheme = null ) {
    18521853        static $cache = array();
    18531854
    1854         $key = sprintf( '%d-%s', get_current_blog_id(), (string) $time );
     1855        $key = sprintf( '%d-%s-%s', get_current_blog_id(), (string) $time, (string) $scheme );
    18551856
    18561857        if ( $refresh_cache || empty( $cache[ $key ] ) ) {
    1857                 $cache[ $key ] = _wp_upload_dir( $time );
     1858                $cache[ $key ] = _wp_upload_dir( $time, $scheme );
    18581859        }
    18591860
    18601861        /**
     
    19001901 * @access private
    19011902 *
    19021903 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
     1904 * @param string $scheme Optional. Scheme to give the uploads url context. See set_url_scheme().
    19031905 * @return array See wp_upload_dir()
    19041906 */
    1905 function _wp_upload_dir( $time = null ) {
     1907function _wp_upload_dir( $time = null, $scheme = null ) {
    19061908        $siteurl = get_option( 'siteurl' );
    19071909        $upload_path = trim( get_option( 'upload_path' ) );
    19081910
     
    19741976                        $url = trailingslashit( $siteurl ) . 'files';
    19751977                }
    19761978        }
     1979       
     1980        $url = set_url_scheme( $url, $scheme );
    19771981
    19781982        $basedir = $dir;
    19791983        $baseurl = $url;
  • wp-includes/media.php

     
    333333
    334334        list( $img_src, $width, $height ) = image_downsize($id, $size);
    335335        $hwstring = image_hwstring($width, $height);
     336       
     337        // Determine the scheme of the image source URL
     338        if ( $url = get_option( 'upload_url_path' ) ) {
     339                $scheme = parse_url( $url, PHP_URL_SCHEME );
     340        } else {
     341                /*
     342                 * The upload_url_path option is not set. Therefore, use the scheme
     343                 * of the WP_CONTENT_URL constant. If it is not set by the user, it
     344                 * defaults to the siteurl option.
     345                 */
     346                $scheme = parse_url( WP_CONTENT_URL, PHP_URL_SCHEME );
     347        }
     348       
     349        $img_src = set_url_scheme( $img_src, $scheme );
    336350
    337351        $title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';
    338352