protected function processVideoIdValue($videoString)
    {
        $video = stripslashes(trim($videoString));
        // check for iframe to get the video url
        if (strpos($video, 'iframe') !== false) {
            // retrieve the video url
            $anchorRegex = '/src="(.*)?"/isU';
            $results = array();
            if (preg_match($anchorRegex, $video, $results)) {
                $link = trim($results[1]);
            }
        } else {
            // we already have a url
            $link = $video;
        }

        // if we have a URL, parse it down
        if (!empty($link)) {
            // initial values
            $id = null;
            $videoIdRegex = null;
            $results = [];
            if (strpos($link, 'youtu') !== false) {
                if (strpos($link, 'youtube.com') !== false) {
                    // works on:
                    // http://www.youtube.com/embed/VIDEOID
                    // http://www.youtube.com/embed/VIDEOID?modestbranding=1&amp;rel=0
                    // http://www.youtube.com/v/VIDEO-ID?fs=1&amp;hl=en_US
                    $videoIdRegex = "/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/";
                } elseif (strpos($link, 'youtu.be') !== false) {
                    // works on:
                    // http://youtu.be/daro6K6mym8
                    $videoIdRegex = '/youtu.be\/([a-zA-Z0-9_-]+)\??/i';
                }

                if ($videoIdRegex !== null) {
                    if (preg_match($videoIdRegex, $link, $results)) {
                        $id = $results[1];
                        $provider = 'youtube';
                    }
                }
            } elseif (strpos($video, 'vimeo') !== false) {
                if (strpos($video, 'player.vimeo.com') !== false) {
                    // works on:
                    // http://player.vimeo.com/video/37985580?title=0&amp;byline=0&amp;portrait=0
                    $videoIdRegex = '/player.vimeo.com\/video\/([0-9]+)\??/i';
                } else {
                    // works on:
                    // http://vimeo.com/37985580
                    $videoIdRegex = '/vimeo.com\/([0-9]+)\??/i';
                }

                if ($videoIdRegex !== null) {
                    if (preg_match($videoIdRegex, $link, $results)) {
                        $id = $results[1];
                        $provider = 'vimeo';
                    }
                }
            }

            if (!empty($id)) {
                return compact('id', 'provider');
            }
        }
    }
protected function processVideoIdValue($videoString)
    {
        $video = stripslashes(trim($videoString));
        // check for iframe to get the video url
        if (strpos($video, 'iframe') !== false) {
            // retrieve the video url
            $anchorRegex = '/src="(.*)?"/isU';
            $results = array();
            if (preg_match($anchorRegex, $video, $results)) {
                $link = trim($results[1]);
            }
        } else {
            // we already have a url
            $link = $video;
        }

        // if we have a URL, parse it down
        if (!empty($link)) {
            // initial values
            $id = null;
            $videoIdRegex = null;
            $results = [];
            if (strpos($link, 'youtu') !== false) {
                if (strpos($link, 'youtube.com') !== false) {
                    // works on:
                    // http://www.youtube.com/embed/VIDEOID
                    // http://www.youtube.com/embed/VIDEOID?modestbranding=1&amp;rel=0
                    // http://www.youtube.com/v/VIDEO-ID?fs=1&amp;hl=en_US
                    $videoIdRegex = "/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/";
                } elseif (strpos($link, 'youtu.be') !== false) {
                    // works on:
                    // http://youtu.be/daro6K6mym8
                    $videoIdRegex = '/youtu.be\/([a-zA-Z0-9_-]+)\??/i';
                }

                if ($videoIdRegex !== null) {
                    if (preg_match($videoIdRegex, $link, $results)) {
                        $id = $results[1];
                        $provider = 'youtube';
                    }
                }
            } elseif (strpos($video, 'vimeo') !== false) {
                if (strpos($video, 'player.vimeo.com') !== false) {
                    // works on:
                    // http://player.vimeo.com/video/37985580?title=0&amp;byline=0&amp;portrait=0
                    $videoIdRegex = '/player.vimeo.com\/video\/([0-9]+)\??/i';
                } else {
                    // works on:
                    // http://vimeo.com/37985580
                    $videoIdRegex = '/vimeo.com\/([0-9]+)\??/i';
                }

                if ($videoIdRegex !== null) {
                    if (preg_match($videoIdRegex, $link, $results)) {
                        $id = $results[1];
                        $provider = 'vimeo';
                    }
                }
            }

            if (!empty($id)) {
                return compact('id', 'provider');
            }
        }
    }
protected function processVideoIdValue ( $ videoString ) { $ video = stripslashes ( trim ( $ videoString ) ) ; // check for iframe to get the video url if ( strpos ( $ video , 'iframe' ) !== false ) { // retrieve the video url $ anchorRegex = '/src="(.*)?"/isU' ; $ results = array ( ) ; if ( preg_match ( $ anchorRegex , $ video , $ results ) ) { $ link = trim ( $ results [ 1 ] ) ; } } else { // we already have a url $ link = $ video ; } // if we have a URL, parse it down if ( ! empty ( $ link ) ) { // initial values $ id = null ; $ videoIdRegex = null ; $ results = [ ] ; if ( strpos ( $ link , 'youtu' ) !== false ) { if ( strpos ( $ link , 'youtube.com' ) !== false ) { // works on: // http://www.youtube.com/embed/VIDEOID // http://www.youtube.com/embed/VIDEOID?modestbranding=1&amp;rel=0 // http://www.youtube.com/v/VIDEO-ID?fs=1&amp;hl=en_US $ videoIdRegex = "/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/" ; } elseif ( strpos ( $ link , 'youtu.be' ) !== false ) { // works on: // http://youtu.be/daro6K6mym8 $ videoIdRegex = '/youtu.be\/([a-zA-Z0-9_-]+)\??/i' ; } if ( $ videoIdRegex !== null ) { if ( preg_match ( $ videoIdRegex , $ link , $ results ) ) { $ id = $ results [ 1 ] ; $ provider = 'youtube' ; } } } elseif ( strpos ( $ video , 'vimeo' ) !== false ) { if ( strpos ( $ video , 'player.vimeo.com' ) !== false ) { // works on: // http://player.vimeo.com/video/37985580?title=0&amp;byline=0&amp;portrait=0 $ videoIdRegex = '/player.vimeo.com\/video\/([0-9]+)\??/i' ; } else { // works on: // http://vimeo.com/37985580 $ videoIdRegex = '/vimeo.com\/([0-9]+)\??/i' ; } if ( $ videoIdRegex !== null ) { if ( preg_match ( $ videoIdRegex , $ link , $ results ) ) { $ id = $ results [ 1 ] ; $ provider = 'vimeo' ; } } } if ( ! empty ( $ id ) ) { return compact ( 'id' , 'provider' ) ; } } }
Processes Video id and gets it from provider url.

@param $videoString

@return mixed

@throws \Exception
Processes Video id and gets it from provider url .