Skip to content

Commit

Permalink
should fix edge case bug with root-relative img paths in subfolder in…
Browse files Browse the repository at this point in the history
…stalls
  • Loading branch information
zytzagoo committed Sep 30, 2018
1 parent 95d91d5 commit b189dc6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion classes/autoptimizeImages.php
Expand Up @@ -325,7 +325,13 @@ private function normalize_img_url( $in )
if ( autoptimizeUtils::is_protocol_relative( $in ) ) {
$result = $parsed_site_url['scheme'] . ':' . $in;
} elseif ( 0 === strpos( $in, '/' ) ) {
$result = $parsed_site_url['scheme'] . '://' . $parsed_site_url['host'] . $in;
// Root-relative...
$result = $parsed_site_url['scheme'] . '://' . $parsed_site_url['host'];
// Add the path for subfolder installs.
if ( isset( $parsed_site_url['path'] ) ) {
$result .= $parsed_site_url['path'];
}
$result .= $in;
}

$result = apply_filters( 'autoptimize_filter_extra_imgopt_normalized_url', $result );
Expand Down Expand Up @@ -501,6 +507,7 @@ public function filter_optimize_images( $in )
}
}
}

$out = str_replace( array_keys( $to_replace ), array_values( $to_replace ), $in );

// img thumbnails in e.g. woocommerce.
Expand Down

0 comments on commit b189dc6

Please sign in to comment.