From 3953a4eb2a1c20268d49fd793e3822617a5e714b Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Tue, 8 Nov 2022 17:22:14 +0000 Subject: [PATCH] Add image generating for background images --- router.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/router.php b/router.php index 52e530c..7a89068 100644 --- a/router.php +++ b/router.php @@ -16,7 +16,7 @@ if (file_exists("site.json")) { return false; } -if (preg_match('/\.(?:jpg|png|webp|css|ico|scss|js|ttf|woff|txt)/', $_SERVER["REQUEST_URI"])) { +if (preg_match('/\.(?:jpg|png|webp|css|ico|js|ttf|woff|txt)/', $_SERVER["REQUEST_URI"])) { return false; } @@ -139,6 +139,9 @@ die(); function img_src($src, $root = "" ) { if (empty($root)) $root = $_SERVER['REQUEST_URI']; if ($root == "/") $root = ""; + + if (substr($root, -1) == '/') $root = substr($root, 0, -1); + if ($src[0] != '/') { $write = "$root/$src"; } else $write = $src; @@ -211,7 +214,7 @@ function make_bkgd_img($src, $q=80) { $pe = ltrim($pwebp, '/'); $we = ltrim($p, '/'); - return "background-image: image-set(url($pe) 1x, url($we) 1x)"; + return "background-image: url($pe); background-image: -webkit-image-set(url($pwebp) 1x, url($p) 1x)"; }