adventskalender/2025/js/background.js aktualisiert
This commit is contained in:
@@ -21,14 +21,12 @@
|
||||
|
||||
const padded = (dayToShow >= 1 && dayToShow <= 24) ? String(dayToShow).padStart(2, "0") : "Basisbild";
|
||||
const filename = padded;
|
||||
const basePath = "assets/images/";
|
||||
const basePath = `/${YEAR}/assets/images/`; // <=== hier angepasst!
|
||||
|
||||
// === Favicon setzen (.webp) ===
|
||||
// Aufruf:
|
||||
setFavicon(`assets/images/1920/webp/${filename}.webp`);
|
||||
setFavicon(`${basePath}1920/webp/${filename}.webp`);
|
||||
|
||||
// Funktion:
|
||||
function setFavicon(path) {
|
||||
function setFavicon(path) {
|
||||
let link = document.querySelector('link[rel="icon"]');
|
||||
if (!link) {
|
||||
link = document.createElement("link");
|
||||
@@ -37,7 +35,7 @@ function setFavicon(path) {
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
link.href = path;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const picture = document.querySelector(".kalenderbild picture");
|
||||
@@ -55,17 +53,17 @@ function setFavicon(path) {
|
||||
if (!format) return;
|
||||
|
||||
const newSrcset = breakpoints
|
||||
.map(bp => `assets/images/${bp}/${format}/${filename}.${format} ${bp}w`)
|
||||
.map(bp => `${basePath}${bp}/${format}/${filename}.${format} ${bp}w`)
|
||||
.join(", ");
|
||||
source.setAttribute("srcset", newSrcset);
|
||||
});
|
||||
|
||||
// === <img> (JPEG-Fallback) responsiv setzen ===
|
||||
const jpegSrcset = breakpoints
|
||||
.map(bp => `assets/images/${bp}/jpeg/${filename}.jpg ${bp}w`)
|
||||
.map(bp => `${basePath}${bp}/jpeg/${filename}.jpg ${bp}w`)
|
||||
.join(", ");
|
||||
|
||||
img.setAttribute("src", `assets/images/1920/jpeg/${filename}.jpg`);
|
||||
img.setAttribute("src", `${basePath}1920/jpeg/${filename}.jpg`);
|
||||
img.setAttribute("srcset", jpegSrcset);
|
||||
img.setAttribute("sizes", "100vw");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user