diff --git a/plugins/system/sef/sef.php b/plugins/system/sef/sef.php index e7c0307be54e5..e6b9185c73eb6 100644 --- a/plugins/system/sef/sef.php +++ b/plugins/system/sef/sef.php @@ -137,12 +137,14 @@ public function onAfterRender() $regex, function ($match) use ($base, $protocols) { - $data = array(); - foreach (explode(",", $match[1]) as $url) + preg_match_all('#(?:[^\s]+)\s*(?:[\d\.]+[wx])?(?:\,\s*)?#i', $match[1], $matches); + + foreach ($matches[0] as &$src) { - $data[] = preg_replace('#^(?!/|' . $protocols . '|\#|\')(.+)#', $base . '$1', trim($url)); + $src = preg_replace('#^(?!/|' . $protocols . '|\#|\')(.+)#', $base . '$1', $src); } - return ' srcset="' . implode(",", $data) . '"'; + + return ' srcset="' . implode($matches[0]) . '"'; }, $buffer );