protected function processYoutube($url)
    {
        $firstMatches = [];
        $pattern = '%^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=))([^"&?/ ]{11})(?:.+)?$%xs';
        if (preg_match($pattern, $url, $firstMatches)) {
            $toEmbed = $firstMatches[1];
            $patternForAdditionalParams = '%^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=))(?:[^"&?\/ ]{11})(.+)?(?:.+)?$%xs';
            $secondMatches = [];
            if (preg_match($patternForAdditionalParams, $url, $secondMatches) > 1) {
                $toEmbed .= '?' . substr($secondMatches[1], 1);
            }
            return 'https://www.youtube-nocookie.com/embed/' . $toEmbed;
        }
        return null;
    }
protected function processYoutube($url)
    {
        $firstMatches = [];
        $pattern = '%^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=))([^"&?/ ]{11})(?:.+)?$%xs';
        if (preg_match($pattern, $url, $firstMatches)) {
            $toEmbed = $firstMatches[1];
            $patternForAdditionalParams = '%^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=))(?:[^"&?\/ ]{11})(.+)?(?:.+)?$%xs';
            $secondMatches = [];
            if (preg_match($patternForAdditionalParams, $url, $secondMatches) > 1) {
                $toEmbed .= '?' . substr($secondMatches[1], 1);
            }
            return 'https://www.youtube-nocookie.com/embed/' . $toEmbed;
        }
        return null;
    }
protected function processYoutube ( $ url ) { $ firstMatches = [ ] ; $ pattern = '%^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=))([^"&?/ ]{11})(?:.+)?$%xs' ; if ( preg_match ( $ pattern , $ url , $ firstMatches ) ) { $ toEmbed = $ firstMatches [ 1 ] ; $ patternForAdditionalParams = '%^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=))(?:[^"&?\/ ]{11})(.+)?(?:.+)?$%xs' ; $ secondMatches = [ ] ; if ( preg_match ( $ patternForAdditionalParams , $ url , $ secondMatches ) > 1 ) { $ toEmbed .= '?' . substr ( $ secondMatches [ 1 ] , 1 ) ; } return 'https://www.youtube-nocookie.com/embed/' . $ toEmbed ; } return null ; }
Processes YouTube url

@param string $url
@return string
Processes YouTube url