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
View File
@@ -247,6 +247,11 @@ Single source of truth per concern — do not duplicate these:
- `cinema.photos[0]` = **รูปปกการ์ดหน้าแรก** (`CinemaCard`) — ไม่มีรูป = ใช้ gradient 4 แบบ (`CARD_GRADIENTS`)
- หน้า detail ใช้ `Gallery`: มีไม่ครบ 3 รูป ช่องที่ว่างแสดง **โลโก้ AlterFlixHub** (ดูหัวข้อโลโก้)
- รูปในเครื่องวางที่ `public/images/…` แล้วใส่ path `/images/…` (ไฟล์ `hero.png` ใช้เป็นพื้นหลังฮีโร่หน้าแรก)
- **ห้ามใช้ลิงก์ hotlink จากภายนอกใน `photos[]`** (Google Maps/`googleusercontent`/`fbcdn`/`gstatic` ฯลฯ) — ลิงก์มีอายุ จำกัด rate และตอบ **200 แต่ 0 ไบต์** ทำให้รูปแตกโดยไม่มี error ให้จับ
- เก็บสำเนาลง `public/images/cinemas/<slug>[-n].<ext>` ด้วย `node scripts/mirror-photos.mjs` (สำรอง `content.json` ให้เอง · `--dry` = ดูเฉย ๆ) แล้ว `photos[]` ชี้ path ในโปรเจกต์
- ตรวจรูปเสียก่อน commit: `node scripts/audit-photos.mjs` (exit 1 = มีรูปพัง)
- ขนาดรูป: กว้างไม่เกิน **1600px** และบีบอัด (JPEG q82 / WebP q82) — โฟลเดอร์ `public/images/cinemas` ควรอยู่ราว **≤ 3 MB**
- **ทุก `<img>` ของโรงหนังต้องใช้ `<PhotoImage>`** (`app/components/site/PhotoImage.tsx`) — มี `onError` สลับไปโลโก้แทนรูปแตก และจำ `src` ที่พังเพื่อให้เปลี่ยนรูปใหม่แล้วโหลดได้อีก (ห้ามเขียน `<img src={photo}>` ตรง ๆ ใน component ใหม่)
## ลำดับการ์ดหน้าแรก (สลับทุกวัน)