youtube: Automatically download and cache thumbnail
This commit is contained in:
parent
6d00ffdffb
commit
40fbcf0308
@ -137,7 +137,11 @@
|
|||||||
} else if (opted_in('y')) {
|
} else if (opted_in('y')) {
|
||||||
echo '<iframe width="100%" height="100%" src="' . $url . '" frameborder="0" allowfullscreen></iframe>';
|
echo '<iframe width="100%" height="100%" src="' . $url . '" frameborder="0" allowfullscreen></iframe>';
|
||||||
} else {
|
} else {
|
||||||
echo "<div style='width:100%;height:100%;background-color:black;background-image: url(" . YT_PREVIEW . $youtube['vid'] . ".jpg);background-size:contain;'><table border=0 style='height:100%;width:100%;background-color:rgba(0,0,0,0.55);backdrop-filter:blur(3px);text-shadow:1px 1px black;'><tr><td style='text-align:center;'>Embedded content has been disabled to protect your privacy.<br><br><br><strong><form action='' method='post'><input type='hidden' name='optin-once' value='y' /><input type='submit' value='Click here to load the videos on this site once,'/></form></strong><br><br><strong><a href='/?p=privacy-controls'>or click here to allow them permanently,</a><br><br><a href=\"" . $youtube['link'] . "\">" . "or click here to watch the video on YouTube:<br>" . $youtube['link'] . "</a></strong><br><br><br>Please note that, by enabling this video, data is transferred <br>to YouTube LLC, and is subject to their privacy policy.</td></tr></table></div>";
|
$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 "<div style='width:100%;height:100%;background-color:black;background-image: url(" . $preview_file . ");background-size:contain;'><table border=0 style='height:100%;width:100%;background-color:rgba(0,0,0,0.55);backdrop-filter:blur(3px);text-shadow:1px 1px black;'><tr><td style='text-align:center;'>Embedded content has been disabled to protect your privacy.<br><br><br><strong><form action='' method='post'><input type='hidden' name='optin-once' value='y' /><input type='submit' value='Click here to load the videos on this site once,'/></form></strong><br><br><strong><a href='/?p=privacy-controls'>or click here to allow them permanently,</a><br><br><a href=\"" . $youtube['link'] . "\">" . "or click here to watch the video on YouTube:<br>" . $youtube['link'] . "</a></strong><br><br><br>Please note that, by enabling this video, data is transferred <br>to YouTube LLC, and is subject to their privacy policy.</td></tr></table></div>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: HTML5 video
|
// TODO: HTML5 video
|
||||||
|
Loading…
Reference in New Issue
Block a user