Fotos in Originalgroesse: hoehere Upload-Grenzen, Vollbildansicht mit Zoom

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvuGvHpbAQ4syfuLuRvutL
This commit is contained in:
Maaxxs 2026-10-19 18:32:55 +02:00
parent 7c980ce73c
commit 8c766093a9
6 changed files with 50 additions and 8 deletions

View file

@ -3,7 +3,7 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: "standalone",
experimental: {
serverActions: { bodySizeLimit: "10mb" },
serverActions: { bodySizeLimit: "100mb" },
},
};

View file

@ -49,7 +49,7 @@ export function ImageManager({ name, initial, multiple = true }: { name: string;
<label className="ad-upload">
<Icon name="image" />
{busy ? "Lädt hoch …" : multiple ? "Bilder hinzufügen" : "Bild wählen"}
<input ref={input} type="file" accept="image/jpeg,image/png,image/webp,image/gif" multiple={multiple} hidden onChange={(e) => onFiles(e.target.files)} />
<input ref={input} type="file" accept="image/jpeg,image/png,image/webp,image/avif,image/gif" multiple={multiple} hidden onChange={(e) => onFiles(e.target.files)} />
</label>
)}
</div>

View file

@ -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<HTMLDialogElement>(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 (
<div className="sm-pdp__gallery">
@ -13,9 +24,9 @@ export function Gallery({ images, alt }: { images: string[]; alt: string }) {
}
return (
<div className="sm-pdp__gallery">
<div className="sm-pdp__main">
<button className="sm-pdp__main" type="button" aria-label="Foto in voller Größe ansehen" onClick={() => dialog.current?.showModal()}>
<img src={images[active]} alt={alt} />
</div>
</button>
{images.length > 1 && (
<div className="sm-pdp__thumbs">
{images.map((src, i) => (
@ -32,6 +43,18 @@ export function Gallery({ images, alt }: { images: string[]; alt: string }) {
))}
</div>
)}
<dialog ref={dialog} className={`sm-lightbox${zoom ? " is-zoomed" : ""}`} aria-label={alt}>
<button className="sm-lightbox__close" type="button" aria-label="Schließen" onClick={() => dialog.current?.close()}>×</button>
<div className="sm-lightbox__stage" onClick={(e) => { if (e.target === e.currentTarget) dialog.current?.close(); }}>
<img src={images[active]} alt={alt} onClick={() => setZoom((z) => !z)} />
</div>
{images.length > 1 && (
<>
<button className="sm-lightbox__nav sm-lightbox__nav--prev" type="button" aria-label="Vorheriges Bild" onClick={() => { setZoom(false); setActive((a) => (a - 1 + images.length) % images.length); }}>‹</button>
<button className="sm-lightbox__nav sm-lightbox__nav--next" type="button" aria-label="Nächstes Bild" onClick={() => { setZoom(false); setActive((a) => (a + 1) % images.length); }}>›</button>
</>
)}
</dialog>
</div>
);
}

View file

@ -6,6 +6,9 @@ import { getCurrentUser, can } from "./auth";
const EXT: Record<string, string> = { "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}`);

View file

@ -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); }

View file

@ -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); }