WordPress.org

Make WordPress Core

Ticket #35045: image_base_url.diff

File image_base_url.diff, 1.0 KB (added by webaware, 5 years ago)

patch to fix

  • wp-includes/media.php

     
    12861286                $image_base_url .= trailingslashit( $dirname );
    12871287        }
    12881288
     1289        // set base url scheme to match image source for consistent comparisons
     1290        if ( strpos( $image_src, '//' ) === 0 ) {
     1291                // protocol-relative URL, no protocol scheme
     1292                $image_base_url = preg_replace( '#^https?://#i', '//', $image_base_url );
     1293        } else {
     1294                $scheme = parse_url( $image_src, PHP_URL_SCHEME );
     1295                $image_base_url = set_url_scheme( $image_base_url, $scheme );
     1296        }
     1297
    12891298        $all_sizes = wp_list_pluck( $image_meta['sizes'], 'file' );
    12901299
    12911300        foreach ( $all_sizes as $key => $file ) {
     
    12931302        }
    12941303
    12951304        // Add the original image.
    1296         $all_sizes[] = $base_url . $image_meta['file'];
     1305        $all_sizes[] = $image_base_url . $image_meta['file'];
    12971306
    12981307        // Bail early if the image src doesn't match any of the known image sizes.
    12991308        if ( ! in_array( $image_src, $all_sizes ) ) {