mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-01-17 21:28:30 +01:00
Prevent accessing explode results when empty
Related to Generate screenshots for links #18
This commit is contained in:
parent
98567b8000
commit
499a876801
@ -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)) {
|
||||
//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';
|
||||
}
|
||||
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';
|
||||
}
|
||||
|
||||
return [
|
||||
|
Loading…
x
Reference in New Issue
Block a user