Skip to content

Commit

Permalink
[4.x] Support YouTube Shorts in embed_code modifier (#9521)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlmaier authored Feb 13, 2024
1 parent dbe2766 commit 384649f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Modifiers/CoreModifiers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2909,10 +2909,19 @@ public function embedUrl($url)
}
}

if (Str::contains($url, 'youtube.com/shorts/')) {
$url = str_replace('shorts/', 'embed/', $url);
}

if (Str::contains($url, 'youtube.com')) {
$url = str_replace('youtube.com', 'youtube-nocookie.com', $url);
}

// This avoids SSL issues when using the non-www version
if (Str::contains($url, '//youtube-nocookie.com')) {
$url = str_replace('//youtube-nocookie.com', '//www.youtube-nocookie.com', $url);
}

return $url;
}

Expand Down

0 comments on commit 384649f

Please sign in to comment.