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;
//Edge case of Youtube only (because of Youtube EU cookie consent)
if (str_contains($url, 'youtube')) {
if (is_null($thumbnail)) {
if (str_contains($url, 'youtube')
&& str_contains($url, 'v=')
&& is_null($thumbnail)
) {
//Formula based on https://stackoverflow.com/a/2068371
$explode = explode('v=', $url);
//https://img.youtube.com/vi/[video-id]/mqdefault.jpg
$thumbnail = 'https://img.youtube.com/vi/'.$explode[1].'/mqdefault.jpg';
}
$thumbnail = 'https://img.youtube.com/vi/' . $explode[1] . '/mqdefault.jpg';
}
return [