Suggested Code Tweak to sbp_rebuilding_css_urls()
-
./inc/css-optimizer.php [96]
function sbp_rebuilding_css_urls($css,$url){ $css_dir = substr($url,0,strrpos($url,'/')); $css = preg_replace("/url\((?!data:)['\"]?([^\/][^'\"\)]*)['\"]?\)/i","url({$css_dir}/$1)",$css);
Change line 3 to:
$css = preg_replace("/url\((?!(data:|http:))['\"]?([^\/][^'\"\)]*)['\"]?\)/i","url({$css_dir}/$1)",$css);
CHANGE:
This adjustment changes thedata:
negative lookahead to(data:|http:)
.REASON:
Data content naturally must be excluded, but so too should full paths.Note, the replace is currently adding the CSS root path, to the url path, even if it is an absolute path, or an alternate domain. This adjustment will exclude urls beginning with “http:” from being altered.
E.X.: Before adjustment:
url(https://yoursite.com/wp-uploads/stuff/image.jpg);
BECOMES:
url(https://yoursite.com/css-path/https://yoursite.com/wp-uploads/stuff/image.jpg);After adjustment, the path is unchanged.
It appears
- The topic ‘Suggested Code Tweak to sbp_rebuilding_css_urls()’ is closed to new replies.