refactor(images): replace raw img tags with next/image in SafeImage, VetGallery, and VideosPage [TASK-107]
This commit is contained in:
1 parent
01f4a7cf57
commit
0f32ec62c1
6 files changed
+34
-16
No files matched your search
@@ -1,9 +1,10 @@
|
||||
"use client";
|
||||
import React from "react";
|
||||
import Image from "next/image";
|
||||
import { ImageOff, Sparkles } from "lucide-react";
|
||||
import { cn } from "../lib/utils";
|
||||
|
||||
interface SafeImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
||||
interface SafeImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'src'> {
|
||||
src?: string;
|
||||
alt?: string;
|
||||
className?: string;
|
||||
@@ -13,7 +14,7 @@ interface SafeImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
||||
|
||||
export default function SafeImage({
|
||||
src,
|
||||
alt,
|
||||
alt = "تصویر مکمل کانینا",
|
||||
className,
|
||||
imgClassName,
|
||||
fallbackText = "در حال بروزرسانی تصویر...",
|
||||
@@ -56,9 +57,12 @@ export default function SafeImage({
|
||||
<Sparkles className="w-6 h-6 text-canina-blue/20" />
|
||||
</div>
|
||||
)}
|
||||
<img
|
||||
<Image
|
||||
src={src}
|
||||
alt={alt}
|
||||
width={500}
|
||||
height={500}
|
||||
unoptimized
|
||||
className={cn(
|
||||
"transition-all duration-700 w-full h-full",
|
||||
imgClassName,
|
||||
@@ -66,8 +70,6 @@ export default function SafeImage({
|
||||
)}
|
||||
onLoad={() => setLoading(false)}
|
||||
onError={() => setError(true)}
|
||||
referrerPolicy="no-referrer"
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { motion, AnimatePresence } from "motion/react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useSettingsStore } from "../lib/store/settingsStore";
|
||||
import SafeImage from "./SafeImage";
|
||||
|
||||
const VIDEOS = [
|
||||
{
|
||||
@@ -77,10 +78,11 @@ export default function VetGallery({ testimonials = [] }: { testimonials?: any[]
|
||||
>
|
||||
<div className="relative aspect-video rounded-[2rem] overflow-hidden mb-4 shadow-xl">
|
||||
<div className="absolute inset-0 bg-medical-gray-900/20 group-hover:bg-transparent transition-colors z-10" />
|
||||
<img
|
||||
<SafeImage
|
||||
src={video.thumbnail || video.imageUrl || '/images/vets/vet1.webp'}
|
||||
alt={video.title || video.vetName}
|
||||
className="w-full h-full object-cover grayscale-[30%] group-hover:grayscale-0 transition-all duration-700"
|
||||
className="w-full h-full"
|
||||
imgClassName="object-cover grayscale-[30%] group-hover:grayscale-0 transition-all duration-700"
|
||||
/>
|
||||
<div className="absolute inset-0 flex items-center justify-center z-20">
|
||||
<div className="w-16 h-16 bg-white/90 backdrop-blur-sm rounded-full flex items-center justify-center text-canina-blue scale-90 group-hover:scale-100 group-hover:bg-white transition-all shadow-xl">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import React, { useState } from "react";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import { ChevronRight, PlayCircle, Star, ShieldCheck, X, Search, Clock, User } from "lucide-react";
|
||||
import SafeImage from "./SafeImage";
|
||||
|
||||
|
||||
const ALL_VIDEOS = [
|
||||
@@ -110,11 +111,11 @@ export default function VideosPage() {
|
||||
onClick={() => setSelectedVideo(video)}
|
||||
>
|
||||
<div className="relative aspect-video rounded-[2.5rem] overflow-hidden mb-6 shadow-2xl border border-white/5">
|
||||
<img
|
||||
<SafeImage
|
||||
src={video.thumbnail}
|
||||
alt={video.title}
|
||||
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-700 opacity-60 group-hover:opacity-100"
|
||||
referrerPolicy="no-referrer"
|
||||
className="w-full h-full"
|
||||
imgClassName="object-cover group-hover:scale-110 transition-transform duration-700 opacity-60 group-hover:opacity-100"
|
||||
/>
|
||||
<div className="absolute inset-0 flex items-center justify-center">
|
||||
<div className="w-16 h-16 bg-canina-blue rounded-full flex items-center justify-center text-white shadow-2xl group-hover:scale-110 transition-transform">
|
||||
|
||||
Reference in new issue
Block a user