Day01 Fehlerbehebung
This commit is contained in:
@@ -19,9 +19,10 @@
|
||||
const sim = getSimulatedDay();
|
||||
if (DEV_MODE && sim) dayToShow = sim;
|
||||
|
||||
const padded = (dayToShow >= 1 && dayToShow <= 24)
|
||||
? String(dayToShow).padStart(2, "0")
|
||||
: "Basisbild";
|
||||
const padded =
|
||||
dayToShow >= 1 && dayToShow <= 24
|
||||
? String(dayToShow).padStart(2, "0")
|
||||
: "Basisbild";
|
||||
|
||||
const filename = padded;
|
||||
const basePath = `/${YEAR}/assets/images/`;
|
||||
@@ -50,23 +51,67 @@
|
||||
|
||||
if (!picture || !img || !sources) return;
|
||||
|
||||
// === Daumenkino (nur für Tag 1) ===
|
||||
if (dayToShow === 1) {
|
||||
const thumbkino = document.querySelector(".thumbkino-video");
|
||||
if (thumbkino) {
|
||||
const formats = ["webm", "mp4"];
|
||||
const resolutions = [
|
||||
"nHD",
|
||||
"FWVGA",
|
||||
"qHD",
|
||||
"HD",
|
||||
"HDplus",
|
||||
"FullHD",
|
||||
"1440p",
|
||||
"4K",
|
||||
];
|
||||
const breakpoints = [640, 854, 960, 1280, 1600, 1920, 2560, 3840];
|
||||
|
||||
// alte Quellen entfernen
|
||||
while (thumbkino.firstChild) thumbkino.removeChild(thumbkino.firstChild);
|
||||
|
||||
formats.forEach((format) => {
|
||||
resolutions.forEach((res, i) => {
|
||||
const mediaQuery =
|
||||
i === resolutions.length - 1
|
||||
? "(min-width: 2561px)"
|
||||
: `(max-width: ${breakpoints[i]}px)`;
|
||||
|
||||
const source = document.createElement("source");
|
||||
source.src = `/${YEAR}/assets/videos/${res}/${format}/${padded}.${format}`;
|
||||
source.type = `video/${format}`;
|
||||
source.media = mediaQuery;
|
||||
thumbkino.appendChild(source);
|
||||
});
|
||||
});
|
||||
|
||||
thumbkino.load();
|
||||
thumbkino.play().catch(() => {});
|
||||
|
||||
console.log(`[Bratonien] Daumenkino gesetzt für Tag ${padded}`);
|
||||
}
|
||||
}
|
||||
|
||||
const breakpoints = [420, 768, 1024, 1366, 1600, 1920, 2560, 3840];
|
||||
|
||||
// === <source> für AVIF und WebP aktualisieren ===
|
||||
sources.forEach(source => {
|
||||
sources.forEach((source) => {
|
||||
const type = source.getAttribute("type");
|
||||
const format = type?.split("/")[1]; // "avif" oder "webp"
|
||||
if (!format) return;
|
||||
|
||||
const newSrcset = breakpoints
|
||||
.map(bp => `${basePath}${bp}/${format}/${filename}.${format} ${bp}w`)
|
||||
.map(
|
||||
(bp) => `${basePath}${bp}/${format}/${filename}.${format} ${bp}w`
|
||||
)
|
||||
.join(", ");
|
||||
source.setAttribute("srcset", newSrcset);
|
||||
});
|
||||
|
||||
// === <img> (JPEG-Fallback) ===
|
||||
const jpegSrcset = breakpoints
|
||||
.map(bp => `${basePath}${bp}/jpeg/${filename}.jpeg ${bp}w`)
|
||||
.map((bp) => `${basePath}${bp}/jpeg/${filename}.jpeg ${bp}w`)
|
||||
.join(", ");
|
||||
|
||||
img.setAttribute("src", `${basePath}1920/jpeg/${filename}.jpeg`);
|
||||
|
||||
Reference in New Issue
Block a user