From 8c766093a939755226de03d956a66c6a5a392ac0 Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Mon, 19 Oct 2026 18:32:55 +0200 Subject: [PATCH] Fotos in Originalgroesse: hoehere Upload-Grenzen, Vollbildansicht mit Zoom Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SvuGvHpbAQ4syfuLuRvutL --- next.config.ts | 2 +- src/components/admin/ImageManager.tsx | 2 +- src/components/shop/Gallery.tsx | 29 ++++++++++++++++++++++++--- src/lib/upload.ts | 7 +++++-- src/styles/bundle.css | 2 +- src/styles/shop.css | 16 +++++++++++++++ 6 files changed, 50 insertions(+), 8 deletions(-) diff --git a/next.config.ts b/next.config.ts index 8a69059..ca374a0 100644 --- a/next.config.ts +++ b/next.config.ts @@ -3,7 +3,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { output: "standalone", experimental: { - serverActions: { bodySizeLimit: "10mb" }, + serverActions: { bodySizeLimit: "100mb" }, }, }; diff --git a/src/components/admin/ImageManager.tsx b/src/components/admin/ImageManager.tsx index 9ccce8f..b13c0ac 100644 --- a/src/components/admin/ImageManager.tsx +++ b/src/components/admin/ImageManager.tsx @@ -49,7 +49,7 @@ export function ImageManager({ name, initial, multiple = true }: { name: string; )} diff --git a/src/components/shop/Gallery.tsx b/src/components/shop/Gallery.tsx index ea64a36..1b81fa2 100644 --- a/src/components/shop/Gallery.tsx +++ b/src/components/shop/Gallery.tsx @@ -1,9 +1,20 @@ "use client"; /* eslint-disable @next/next/no-img-element */ -import { useState } from "react"; +import { useEffect, useRef, useState } from "react"; export function Gallery({ images, alt }: { images: string[]; alt: string }) { const [active, setActive] = useState(0); + const [zoom, setZoom] = useState(false); + const dialog = useRef(null); + + useEffect(() => { + const d = dialog.current; + if (!d) return; + const onClose = () => setZoom(false); + d.addEventListener("close", onClose); + return () => d.removeEventListener("close", onClose); + }, []); + if (images.length === 0) { return (
@@ -13,9 +24,9 @@ export function Gallery({ images, alt }: { images: string[]; alt: string }) { } return (
-
+
+ {images.length > 1 && (
{images.map((src, i) => ( @@ -32,6 +43,18 @@ export function Gallery({ images, alt }: { images: string[]; alt: string }) { ))}
)} + + +
{ if (e.target === e.currentTarget) dialog.current?.close(); }}> + {alt} setZoom((z) => !z)} /> +
+ {images.length > 1 && ( + <> + + + + )} +
); } diff --git a/src/lib/upload.ts b/src/lib/upload.ts index 1df1631..8fb92af 100644 --- a/src/lib/upload.ts +++ b/src/lib/upload.ts @@ -6,6 +6,9 @@ import { getCurrentUser, can } from "./auth"; const EXT: Record = { "image/jpeg": ".jpg", "image/png": ".png", "image/webp": ".webp", "image/gif": ".gif", "image/avif": ".avif" }; +// Bilder werden unverändert in Originalgröße gespeichert, nicht verkleinert oder neu komprimiert. +const MAX_MB = 25; + export async function uploadImages(fd: FormData): Promise<{ urls: string[]; error?: string }> { const user = await getCurrentUser(); if (!can(user, "products.edit") && !can(user, "categories.edit") && !can(user, "appearance.edit")) return { urls: [], error: "Dafür fehlt dir das Recht." }; @@ -15,8 +18,8 @@ export async function uploadImages(fd: FormData): Promise<{ urls: string[]; erro for (const file of fd.getAll("files")) { if (!(file instanceof File) || file.size === 0) continue; const ext = EXT[file.type]; - if (!ext) return { urls, error: `${file.name}: Bitte JPG, PNG, WebP oder GIF hochladen.` }; - if (file.size > 8 * 1024 * 1024) return { urls, error: `${file.name} ist größer als 8 MB.` }; + if (!ext) return { urls, error: `${file.name}: Bitte JPG, PNG, WebP, AVIF oder GIF hochladen. iPhone-Fotos (HEIC) wandelt das iPhone beim Hochladen automatisch um.` }; + if (file.size > MAX_MB * 1024 * 1024) return { urls, error: `${file.name} ist größer als ${MAX_MB} MB.` }; const name = `${Date.now().toString(36)}-${randomBytes(6).toString("hex")}${ext}`; await writeFile(path.join(dir, name), Buffer.from(await file.arrayBuffer())); urls.push(`/uploads/${name}`); diff --git a/src/styles/bundle.css b/src/styles/bundle.css index cc7bd07..bc8fe64 100644 --- a/src/styles/bundle.css +++ b/src/styles/bundle.css @@ -137,7 +137,7 @@ button { font: inherit; color: inherit; } .sm-card { position: relative; display: flex; flex-direction: column; gap: var(--space-3); color: var(--ink); text-decoration: none; } .sm-card__media { position: relative; overflow: hidden; border-radius: var(--radius-md); background: var(--surface-sunken); aspect-ratio: var(--product-image-ratio); } .sm-card__media > img, .sm-card__media > .sm-ph { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms ease; } -.sm-card:hover .sm-card__media > img, .sm-card:hover .sm-card__media > .sm-ph { transform: scale(1.03); } +.sm-card:hover .sm-card__media > .sm-ph { transform: scale(1.03); } .sm-card__badges { position: absolute; top: var(--space-3); left: var(--space-3); display: flex; gap: var(--space-1); z-index: 1; } .sm-card__wish { position: absolute; top: var(--space-2); right: var(--space-2); z-index: 1; width: var(--touch-target); height: var(--touch-target); display: grid; place-content: center; border: 0; border-radius: var(--radius-pill); background: var(--surface-raised); color: var(--ink); cursor: pointer; box-shadow: var(--shadow-sm); } .sm-card__wish:hover { color: var(--gold-deep); } diff --git a/src/styles/shop.css b/src/styles/shop.css index e86772e..33abf76 100644 --- a/src/styles/shop.css +++ b/src/styles/shop.css @@ -113,3 +113,19 @@ h1, h2, h3 { margin: 0; } .sm-form-row > .sm-field > .sm-field__label { align-self: end; } } } + +/* Produktfoto in voller Größe */ +button.sm-pdp__main { display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in; } +.sm-pdp__main img { width: 100%; height: 100%; object-fit: cover; } +.sm-lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(12, 11, 9, 0.94); color: #fff; } +.sm-lightbox::backdrop { background: rgba(12, 11, 9, 0.94); } +.sm-lightbox__stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: auto; } +.sm-pdp__gallery .sm-lightbox__stage img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; } +.sm-lightbox.is-zoomed .sm-lightbox__stage { display: block; } +.sm-pdp__gallery .sm-lightbox.is-zoomed .sm-lightbox__stage img { max-width: none; max-height: none; cursor: zoom-out; } +.sm-lightbox__close, .sm-lightbox__nav { position: fixed; z-index: 1; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(12, 11, 9, 0.6); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; } +.sm-lightbox__close { top: 16px; right: 16px; } +.sm-lightbox__nav { top: 50%; transform: translateY(-50%); } +.sm-lightbox__nav--prev { left: 16px; } +.sm-lightbox__nav--next { right: 16px; } +.sm-lightbox__close:hover, .sm-lightbox__nav:hover { background: rgba(12, 11, 9, 0.85); }