Image not loading on vercel prod
Unanswered
Champagne D’Argent posted this in #help-forum
Champagne D’ArgentOP
Any idea why images are not loading on vercel deployment, locally they show up doing pnpm dev they also work if I locally run pnpm build and pnpm start I am confused why theey do not work on vercel prod
22 Replies
@Champagne D’Argent  Any idea why images are not loading on vercel deployment, locally they show up doing pnpm dev they also work if I locally run pnpm build and pnpm start I am confused why theey do not work on vercel prod 
You can upload image other platform and get link and use the link.
Then, it will work.
Champagne D’ArgentOP
@Jerico Aragon it is static image if I upload on another plattform and link it works. But why would I have to do that?
So it is a vercel issue?
I do not want to upload like 10 images for a one pager app on a s3 bucket to make it work...
@Champagne D’Argent  <@461479481626853387> it is static image if I upload on another plattform and link it works. But why would I have to do that? 
That's not vercel issue.
It's your problem.
It's your problem.
Champagne D’ArgentOP
if I run pnpm build then pnpm start locally it works fine
just not when I deploy on vercel
@Champagne D’Argent  if I run pnpm build then pnpm start locally it works fine 
can you share your code?
Champagne D’ArgentOP
This is the code
'use client'
import { useEffect, useRef, useState } from 'react'
import { AnimatePresence, motion } from 'motion/react'
import Image from 'next/image'
const featuredPerson = {
  name: 'Sample Artist',
  role: 'DJ / Producer',
  location: 'Berlin, Germany',
  images: ['/images/sample/1.jpg', '/images/sample/2.jpg'],
  videos: ['/videos/sample/video_1.mp4', '/videos/sample/video_2.mp4'],
}
export default function FeaturedCard() {
  const [i, setI] = useState(0)
  const [isVideo, setIsVideo] = useState(true)
  const [loaded, setLoaded] = useState(false)
  const videoRef = useRef<HTMLVideoElement>(null)
  const media = [
    ...featuredPerson.videos.map((v) => ({ type: 'video' as const, src: v })),
    ...featuredPerson.images.map((i) => ({ type: 'image' as const, src: i })),
  ]
  useEffect(() => {
    const next = (i + 1) % media.length
    if (media[next].type === 'image') new window.Image().src = media[next].src
  }, [i, media])
  const item = media[i]
  const { name } = featuredPerson
  return (
    <div>
      <AnimatePresence mode='wait'>
        <motion.div
          key={i}
          initial={{ opacity: 0 }}
          animate={{ opacity: 1 }}
          exit={{ opacity: 0 }}
          transition={{ duration: 0.4 }}
          className='absolute inset-0'
        >
          {isVideo ? (
            <video
              ref={videoRef}
              src={item.src}
              autoPlay
              loop
              muted
              playsInline
              className='h-full w-full object-cover object-center'
              onLoadedData={() => setLoaded(true)}
            />
          ) : (
            <Image
              src={item.src}
              alt={`${name} - ${i}`}
              fill
              className='object-cover object-top'
              priority={!i}
              onLoad={() => setLoaded(true)}
            />
          )}
        </motion.div>
      </AnimatePresence>
    </div>
  )
}@Jerico Aragon  Let me know your vercel domain 
Champagne D’ArgentOP
[piertronic.events](https://piertronic.events/)
Some image loaded and some unloaded.
Champagne D’ArgentOP
the images from unsplash are loading but the images locally do not load
@Champagne D’Argent  the images from unsplash are loading but the images locally do not load 
I hope to check your project
which image isn't showing?
Champagne D’ArgentOP
@alfonsüs ardani I "fixed" the images, I transformed them to .webp instead of having jpgs and pngs and that worked strangely, but I still have issues with the video files (.mp4 file) they are not loading on vercel.