i have a website which is a forum, and i have a youtube kategory on that website.
my user who has been registered in my website is able to post their youtube video and i use this code to detect the input field for the youtube video
^(?:([a-zA-Z0-9_\-+]{8,16})$|https?\://(?:[a-z]{1,4}\.)?(?:youtube\.com/(?:embed/|v/|watch\?v=)|youtu\.be/)([a-zA-Z0-9_\-+]{8,16}))
this will detect if they fill in the input form with youtube video url or just youtube ID, and then it will change to https://www.youtube.com/embed/slBEtqC_JsI and it works well.
now i want to get and the thumbnail from the youtube video url
so the url https://www.youtube.com/watch?v=slBEtqC_JsI will change to https://i.ytimg.com/vi/slBEtqC_JsI/hqdefault.jpg
my question is, how to call the preg_replace function to replace that code?
i already make this one
$soc_youtube_url = htmlspecialchars_uni($thread['soc_youtube']);
$soc_youtube = preg_replace("^(?:([a-zA-Z0-9_\-+]{8,16})$|https?\://(?:[a-z]{1,4}\.)?(?:youtube\.com/(?:embed/|v/|watch\?v=)|youtu\.be/)([a-zA-Z0-9_\-+]{8,16}))", $soc_youtube_url, $soc_youtube);
for your information the string $soc_youtube_url = htmlspecialchars_uni($thread['soc_youtube']) will produce
https://i.ytimg.com/vi/https://www.youtube.com/watch?v=slBEtqC_JsI/hqdefault.jpg
what i need to replace that code and become https://i.ytimg.com/vi/slBEtqC_JsI/hqdefault.jpg