1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-01-18 05:38:40 +01:00

Prevent accessing explode results when empty

Related to Generate screenshots for links #18
This commit is contained in:
Jesus Ortega 2021-04-17 13:13:57 +02:00
parent 98567b8000
commit 499a876801

View File

@ -67,13 +67,14 @@ class HtmlMeta
?? null; ?? null;
//Edge case of Youtube only (because of Youtube EU cookie consent) //Edge case of Youtube only (because of Youtube EU cookie consent)
if (str_contains($url, 'youtube')) { if (str_contains($url, 'youtube')
if (is_null($thumbnail)) { && str_contains($url, 'v=')
//Formula based on https://stackoverflow.com/a/2068371 && is_null($thumbnail)
$explode = explode('v=', $url); ) {
//https://img.youtube.com/vi/[video-id]/mqdefault.jpg //Formula based on https://stackoverflow.com/a/2068371
$thumbnail = 'https://img.youtube.com/vi/'.$explode[1].'/mqdefault.jpg'; $explode = explode('v=', $url);
} //https://img.youtube.com/vi/[video-id]/mqdefault.jpg
$thumbnail = 'https://img.youtube.com/vi/' . $explode[1] . '/mqdefault.jpg';
} }
return [ return [