I have 2 WP_Editors, 1 is the main editor I use for content and the 2nd is an editor I use for the user to insert videos and any extra content describing the video. My question is, is there an easy way to pull the video URL before (during or after) oEmbed grabs it? I've tried to use a preg_match
but feel that there's too many variations of the youtube URL to find efficiently.
Here's what I've tried:
$videoContent = get_post_meta($post->ID, 'videoContent', true);
$search = '#(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch?.*?v=))([\w\-]{10,12})#x';
$url = preg_match($search, $videoContent);
print_r($url);
I've tried to search around but can't seem to enter the correct keywords to pull up anything useful, only 'how to embed' and such.