mirror_match/components/PhotoImage.tsx
ilia 9640627972
Some checks failed
CI / skip-ci-check (pull_request) Successful in 1m19s
CI / lint-and-type-check (pull_request) Failing after 1m37s
CI / test (pull_request) Successful in 2m16s
CI / build (pull_request) Failing after 1m46s
CI / secret-scanning (pull_request) Successful in 1m20s
CI / dependency-scan (pull_request) Successful in 1m27s
CI / sast-scan (pull_request) Successful in 2m29s
CI / workflow-summary (pull_request) Successful in 1m18s
feat: Add photo management features, duplicate detection, attempt limits, and admin deletion
- Add duplicate photo detection (file hash and URL checking)
- Add max attempts per photo with UI counter
- Simplify penalty system (auto-enable when points > 0)
- Prevent scores from going below 0
- Add admin photo deletion functionality
- Improve navigation with always-visible logout
- Prevent users from guessing their own photos
2026-01-02 14:57:30 -05:00

38 lines
1.2 KiB
TypeScript

"use client"
import Image from "next/image"
export default function PhotoImage({ src, alt }: { src: string; alt: string }) {
// Handle external URLs and local paths
const isExternal = src.startsWith("http://") || src.startsWith("https://")
if (isExternal) {
return (
/* eslint-disable-next-line @next/next/no-img-element */
<img
src={src}
alt={alt}
className="w-full h-full object-contain"
style={{ maxHeight: "100%" }}
loading="lazy"
onError={(e) => {
const target = e.target as HTMLImageElement
target.src = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='600'%3E%3Crect fill='%23ddd' width='800' height='600'/%3E%3Ctext fill='%23999' font-family='sans-serif' font-size='20' dy='10.5' font-weight='bold' x='50%25' y='50%25' text-anchor='middle'%3EImage not found%3C/text%3E%3C/svg%3E"
}}
/>
)
}
return (
<Image
src={src}
alt={alt}
fill
className="object-contain"
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 600px"
loading="lazy"
unoptimized={src.startsWith("/uploads/")}
/>
)
}