|
@@ -97,11 +97,11 @@ discard block |
|
|
block discarded – undo |
|
97
|
97
|
$parsed_url = parse_url( $url ); |
|
98
|
98
|
|
|
99
|
99
|
//Check if image is hosted on current site url -OR- the CDN url specified. Using strpos because we're comparing the host to a full CDN url. |
|
100
|
|
- if ( |
|
101
|
|
- isset( $parsed_url['host'], $parsed_url['path'] ) |
|
102
|
|
- && ($parsed_url['host'] === parse_url( home_url( '/' ), PHP_URL_HOST ) || ( isset($this->options['external_cdn_link']) && ! empty($this->options['external_cdn_link']) && strpos( $this->options['external_cdn_link'], $parsed_url['host']) !== false ) ) |
|
103
|
|
- && preg_match( '/\.(jpg|jpeg|gif|png)$/i', $parsed_url['path'] ) |
|
104
|
|
- ) { |
|
|
100
|
+ if ( |
|
|
101
|
+ isset( $parsed_url['host'], $parsed_url['path'] ) |
|
|
102
|
+ && ($parsed_url['host'] === parse_url( home_url( '/' ), PHP_URL_HOST ) || ( isset($this->options['external_cdn_link']) && ! empty($this->options['external_cdn_link']) && strpos( $this->options['external_cdn_link'], $parsed_url['host']) !== false ) ) |
|
|
103
|
+ && preg_match( '/\.(jpg|jpeg|gif|png)$/i', $parsed_url['path'] ) |
|
|
104
|
+ ) { |
|
105
|
105
|
$cdn = parse_url( $this->options['cdn_link'] ); |
|
106
|
106
|
foreach ( [ 'scheme', 'host', 'port' ] as $url_part ) { |
|
107
|
107
|
if ( isset( $cdn[ $url_part ] ) ) { |
|
@@ -111,10 +111,10 @@ discard block |
|
|
block discarded – undo |
|
111
|
111
|
} |
|
112
|
112
|
} |
|
113
|
113
|
if ( ! empty( $this->options['external_cdn_link'] ) ) { |
|
114
|
|
- //Modify the CDN URL, we won't need any parts after the host. |
|
115
|
|
- $parsed_cdn_url = parse_url( $this->options['external_cdn_link'] ); |
|
116
|
|
- $parsed_url['path'] = str_replace( $parsed_cdn_url['path'], "", $parsed_url['path'] ); |
|
117
|
|
- } |
|
|
114
|
+ //Modify the CDN URL, we won't need any parts after the host. |
|
|
115
|
+ $parsed_cdn_url = parse_url( $this->options['external_cdn_link'] ); |
|
|
116
|
+ $parsed_url['path'] = str_replace( $parsed_cdn_url['path'], "", $parsed_url['path'] ); |
|
|
117
|
+ } |
|
118
|
118
|
|
|
119
|
119
|
$url = http_build_url( $parsed_url ); |
|
120
|
120
|
|
|
@@ -204,7 +204,7 @@ discard block |
|
|
block discarded – undo |
|
204
|
204
|
* @return string |
|
205
|
205
|
*/ |
|
206
|
206
|
public function replace_images_in_content( $content ) { |
|
207
|
|
- // Added null to apply filters wp_get_attachment_url to improve compatibility with https://en-gb.wordpress.org/plugins/amazon-s3-and-cloudfront/ - does not break wordpress if the plugin isn't present. |
|
|
207
|
+ // Added null to apply filters wp_get_attachment_url to improve compatibility with https://en-gb.wordpress.org/plugins/amazon-s3-and-cloudfront/ - does not break wordpress if the plugin isn't present. |
|
208
|
208
|
if ( ! empty ( $this->options['cdn_link'] ) ) { |
|
209
|
209
|
if ( preg_match_all( '/<img\s[^>]*src=([\"\']??)([^\" >]*?)\1[^>]*>/iU', $content, $matches ) ) { |
|
210
|
210
|
foreach ( $matches[2] as $image_src ) { |