From 8fa149be7600d7e6603e13fa5208fb7edfe9a45c Mon Sep 17 00:00:00 2001 From: Syed Zabiuddin <32957211+Zabi09@users.noreply.github.com> Date: Mon, 27 Apr 2020 14:19:09 +0530 Subject: [PATCH] #4342 code improvements --- templates/features.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/features.php b/templates/features.php index 901ce8aae..753ff17b0 100644 --- a/templates/features.php +++ b/templates/features.php @@ -8446,7 +8446,8 @@ function ampforwp_wp_rocket_compatibility($content){ $cdn_url = get_option('wp_rocket_settings'); if($cdn_url['cdn'] == 1){ $cdn_url = $cdn_url["cdn_cnames"][0]; - $content = preg_replace('/src="(.*?)wp-content(.*?)"(.*?)>/', 'src="'.$cdn_url.'/wp-content$2"$3>', $content); + $content = preg_replace('/src="(.*?)\/\/(.*?)wp-content(.*?)"(.*?)>/', 'src="$1//'.$cdn_url.'/wp-content$3"$4>', $content); + $content = preg_replace('/srcset="(.*?)\/\/(.*?)wp-content(.*?),(.*?)\/\/(.*?)wp-content(.*?),(.*?)\/\/(.*?)wp-content(.*?)"/', 'srcset="$1//'.$cdn_url.'/wp-content$3,$4//'.$cdn_url.'/wp-content$6,$7//'.$cdn_url.'/wp-content$9"', $content); } } return $content;