From 40fbcf0308599a94ef986c8cffd6de6ff044d7e7 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Tue, 2 Nov 2021 21:00:10 +0100 Subject: [PATCH] youtube: Automatically download and cache thumbnail --- shared.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shared.php b/shared.php index 59fc471..ee87b4d 100644 --- a/shared.php +++ b/shared.php @@ -137,7 +137,11 @@ } else if (opted_in('y')) { echo ''; } else { - echo "
Embedded content has been disabled to protect your privacy.




or click here to allow them permanently,

" . "or click here to watch the video on YouTube:
" . $youtube['link'] . "



Please note that, by enabling this video, data is transferred
to YouTube LLC, and is subject to their privacy policy.
"; + $preview_file = YT_PREVIEW . $youtube['vid'] . ".jpg"; + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $preview_file)) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . $preview_file, file_get_contents("https://img.youtube.com/vi/" . $youtube['vid'] . "/maxresdefault.jpg")); + } + echo "
Embedded content has been disabled to protect your privacy.




or click here to allow them permanently,

" . "or click here to watch the video on YouTube:
" . $youtube['link'] . "



Please note that, by enabling this video, data is transferred
to YouTube LLC, and is subject to their privacy policy.
"; } } else { // TODO: HTML5 video