Skip to main content
Version: Fegg 5.x

Embed::isYoutubeEmbed

Check whether a URL is a YouTube player URL

Description​

public static bool Embed::isYoutubeEmbed( string $src )

Returns true when $src is a YouTube player URL that may be saved as the src of an iframe: https://www.youtube.com/embed/... or https://www.youtube-nocookie.com/embed/..., with only simple parameters. Fegg\Cms\HtmlSanitizer keeps the iframes of the editor's text whose src this method (or Embed::isMapEmbed) accepts.

To read the URL of a video page, use Embed::youtubeUrl.

Arguments​

NameData typeDefaultRemarks
$srcstringURL to check

Example​

Controller
use Fegg\Tool\Embed;

Embed::isYoutubeEmbed('https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?start=90'); // -> true
Embed::isYoutubeEmbed('https://www.youtube.com/watch?v=dQw4w9WgXcQ'); // -> false