fix(photos): รูปโรงหนังแตก — mirror รูปภายนอกมาเก็บในโปรเจกต์ + fallback

สาเหตุ: photos[] อ้างลิงก์ hotlink (googleusercontent/gstatic/fbcdn ฯลฯ)
ซึ่งตอบ 200 แต่ 0 ไบต์เมื่อลิงก์หมดอายุ/ถูกจำกัด rate → รูปแตกเงียบ ๆ
เช่น /cinema/phahol-theatre

- scripts/mirror-photos.mjs: ดาวน์โหลด 20 รูปจาก 12 โรง มาเก็บ public/images/cinemas
  แล้วแก้ content.json ชี้ path ในโปรเจกต์ (สำรอง .bak-photos-* ก่อนเขียน) → เหลือรูปภายนอก 0
- บีบอัดรูปใหญ่ (<=1600px, q82): 6.12 MB → 2.91 MB
- PhotoImage: img + onError fallback เป็นโลโก้ (ใช้ใน CinemaCard/Gallery) กันรูปแตกทุกกรณี
- scripts/audit-photos.mjs: ตรวจรูปเสีย exit 1
- DESIGN.md: กฎรูปภาพ (ห้าม hotlink, ต้องใช้ PhotoImage, เพดานขนาด)
This commit is contained in:
Bkk1234 committed 2026-11-15 22:32:52 +07:00
1 parent f3798e40da
commit 251932e548
27 files changed
+300 -15

No files matched your search

+5 -12
View File
@@ -2,6 +2,7 @@ import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
import { useState, type ReactNode } from "react";
import { Logo } from "@/components/site/Logo";
import { PhotoImage } from "@/components/site/PhotoImage";
import { rotateGallery, splitGallery } from "@/lib/gallery";
import { useI18n } from "@/lib/i18n";
@@ -19,21 +20,13 @@ type GallerySlotProps = {
};
function GallerySlot({ photo, alt, placeholder, className }: GallerySlotProps) {
if (!photo) {
return (
<div
className={`flex items-center justify-center bg-[#242424] text-sm text-[#999] ${className}`}
>
{placeholder}
</div>
);
}
return (
<img
<PhotoImage
src={photo}
alt={alt}
className={`bg-[#242424] object-cover ${className}`}
size="sm"
className={className}
fallback={placeholder}
/>
);
}