withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.3k stars 2.45k forks source link

astro/Image integrations work locally but not on production #5389

Closed donaldjewkes closed 1 year ago

donaldjewkes commented 1 year ago

What version of astro are you using?

1.6.7

Are you using an SSR adapter? If so, which one?

Netlify

What package manager are you using?

npm

What operating system are you using?

Windows

Describe the Bug

I am having an issue where astro/Image's and tags are working with a local file path but not on production. I have read the documentation and looked at the following similar issues:

https://github.com/withastro/astro/issues/5008 https://github.com/withastro/astro/issues/772

I've tried a lot of different import() path permutations and have attempted to use local files in /src and remote files in /public.

I have been trying to get images to work in this file in my repo https://github.com/donaldjewkes/site/blob/master/src/pages/photos.astro

The Images appear locally with npm run dev but the images don't render with npm run preview. Looking in /dist it seems that there is a suffix added to resized images with the <Image> integration. For some reason these don't appear in my output directory.

ie. The original file appears in /dist like so: /assets/van3.742ef038.jpg But the compressed and resized file /assets/van3.742ef038_Z2rGreV.jpg does not appear.

I'm not sure if this is a bug or an environment issue on my end.

Thanks for any help.

Link to Minimal Reproducible Example

https://github.com/donaldjewkes/site Deployed version here: https://master--jovial-cranachan-094642.netlify.app/photos/

Participation

matthewp commented 1 year ago

This should be fixed by https://github.com/withastro/astro/pull/5361

donaldjewkes commented 1 year ago

This worked, thanks Matthew!

railsfactory-robin commented 1 month ago
import { getImage } from "astro:assets";
    const processedImage = await getImage({
        src: url,
        width: width,
        height: height,
        format: "webp",
      });

processed image in local - http://localhost:4321/_image?href=https%3A%2F%2Fstaging-sedin-cms.s3.us-east-1.amazonaws.com%2Fb3c4bd888402bd54fc3250dc61fd1e08_b212021441.jpeg&w=480&h=320&f=webp - this is loading

after building - astro build if serve the dist directory there the image is not loading why?. getting 404 error

from strapi im using s3 to store my image,

astro.config


  image: {
    remotePatterns: [{ protocol: "https" }],
    domains: ['staging-test-cms.s3.us-east-1.amazonaws.com'],
  }