Closed DCLangX closed 1 year ago
This is intended, remote images do not get optimized or resized. The docs is a bit fuzzy, but it's mentioned in this section: https://docs.astro.build/en/guides/assets/#update-your-markdown-mdx-and-markdoc-files
@Princesseuh this wasn't immediately apparent to me in the docs, either; I dug through the code to find a comment that made it clear remote images aren't optimized by either local image service.
Am I missing some obvious reason why I should not submit a PR for adding remote image support?
@Princesseuh this wasn't immediately apparent to me in the docs, either; I dug through the code to find a comment that made it clear remote images aren't optimized by either local image service.
Am I missing some obvious reason why I should not submit a PR for adding remote image support?
We purposely left it out from a first version of astro:assets
for multiple reasons:
If you're interested in pushing forward a proposal for this, feel free to create a thread over at https://github.com/withastro/roadmap
Hello, I also ran into this problem as the documentation is very lacking in this area. Is there any way of getting remote image optimization to work. Or any other options in the meantime?
Hello, I also ran into this problem as the documentation is very lacking in this area. Is there any way of getting remote image optimization to work. Or any other options in the meantime?
The latest version supports remote images. Just make sure the domains are allowed in your config https://docs.astro.build/en/guides/assets/#allowed-domains-and-remote-patterns-for-remote-images
Hello, I also ran into this problem as the documentation is very lacking in this area. Is there any way of getting remote image optimization to work. Or any other options in the meantime?
The latest version supports remote images. Just make sure the domains are allowed in your config https://docs.astro.build/en/guides/assets/#allowed-domains-and-remote-patterns-for-remote-images
Thanks for the response, does this optimize the remote images because in my testing no optimization was done? I tried local images and those worked perfectly.
Hello, I also ran into this problem as the documentation is very lacking in this area. Is there any way of getting remote image optimization to work. Or any other options in the meantime?
The latest version supports remote images. Just make sure the domains are allowed in your config https://docs.astro.build/en/guides/assets/#allowed-domains-and-remote-patterns-for-remote-images
Thanks for the response, does this optimize the remote images because in my testing no optimization was done? I tried local images and those worked perfectly.
Yes, remote images do get optimized with this.
Hello, I also ran into this problem as the documentation is very lacking in this area. Is there any way of getting remote image optimization to work. Or any other options in the meantime?
The latest version supports remote images. Just make sure the domains are allowed in your config https://docs.astro.build/en/guides/assets/#allowed-domains-and-remote-patterns-for-remote-images
Thanks for the response, does this optimize the remote images because in my testing no optimization was done? I tried local images and those worked perfectly.
Yes, remote images do get optimized with this.
Thanks for confirming this. I am unable to get remote images to work. Right now I have a Strapi CMS running on port 1337 and my config file looks like this
export default defineConfig({
integrations: [
react(),
tailwind(),
partytown({
config: {
forward: ["dataLayer.push"],
},
}),
],
experimental: {
assets: true,
},
compressHTML: true,
cacheDir: ".cache",
image: {
service: {
entrypoint: "astro/assets/services/squoosh",
},
remotePatterns: [
{
hostname: strapiUrl + "/uploads",
protocol: "http",
},
],
},
});
I also tried to optimize images from other websites and this also did not work. Any idea on how to fix this, or a working example config for remote images so I can find out where my code is breaking.
Actually just updated to the latest version that was released a couple hours ago and it started working
What version of
astro
are you using?2.5.6
Are you using an SSR adapter? If so, which one?
none
What package manager are you using?
pnpm
What operating system are you using?
windows
What browser are you using?
chrome
Describe the Bug
I try to generate an optimized remote image by use getImage(),but it doesn't work,the image is still the original address😥
Link to Minimal Reproducible Example
https://github.com/DCLangX/test-astro
Participation