includeGraphics: Clean up thumbnail generation

master
Markus Koch 2021-11-02 21:17:56 +01:00
parent bb6ef06207
commit 7b17d29094
1 changed files with 3 additions and 3 deletions

View File

@ -6,7 +6,7 @@
define('HOME_PAGE', 'blog'); // Entry page (and link for logo)
define('CACHE_POSTS_TTL', 3600); // Time to cache the posts list (1h)
define('POSTS_BASE', "/b/"); // Root directory of the posts (relative)
define('YT_PREVIEW', "/b/pimg-yt/"); // Directory containing local copies of the youtube thumbnails
define('PREVIEW_BASE', "/pimg/"); // Directory to store auto-generated thumbnails
define('POSTS_ROOT', $_SERVER['DOCUMENT_ROOT'] . POSTS_BASE); // Root directory of the posts (absolute)
define('POSTS_PAGE_SIZE', 10); // Numbers of posts on a page
@ -75,7 +75,7 @@
}
if ($preview == "+") {
$previewPath = POSTS_BASE . "pimg/" . str_replace("/", "_", $path);
$previewPath = PREVIEW_BASE . str_replace("/", "_", $path);
$fpreviewPath = $_SERVER['DOCUMENT_ROOT'] . $previewPath;
if (!file_exists($fpreviewPath)) {
preg_match("/^[A-Za-z_\.\-0-9\/]*$/", $fpath, $matches); // SANITIZED!
@ -137,7 +137,7 @@
} else if (opted_in('y')) {
echo '<iframe width="100%" height="100%" src="' . $url . '" frameborder="0" allowfullscreen></iframe>';
} else {
$preview_file = YT_PREVIEW . $youtube['vid'] . ".jpg";
$preview_file = PREVIEW_BASE . $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"));
}