Skip to content

Commit

Permalink
Update sef.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Demmer committed Apr 14, 2017
1 parent 732d33d commit 0e0f476
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions plugins/system/sef/sef.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,21 @@ public function onAfterRender()
if (strpos($buffer, 'srcset=') !== false)
{
$regex = '#\s+srcset="([^"]+)"#m';
$buffer = preg_replace_callback($regex, function ($match) use ($base, $protocols) {
$data = array();
foreach (explode(",", $match[1]) as $url)

$buffer = preg_replace_callback(
$regex,
function ($match) use ($base, $protocols)
{
$data[] = preg_replace('#(?!/|' . $protocols . '|\#|\')([^\s]+)\s+(.*)#', $base . '$1 $2', $url);
}
return ' srcset="' . implode(",", $data) . '"';
}, $buffer);
$data = array();
foreach (explode(",", $match[1]) as $url)
{
$data[] = preg_replace('#(?!/|' . $protocols . '|\#|\')([^\s]+)\s+(.*)#', $base . '$1 $2', $url);
}
return ' srcset="' . implode(",", $data) . '"';
},
$buffer
);

$this->checkBuffer($buffer);
}

Expand Down

0 comments on commit 0e0f476

Please sign in to comment.