#Images not loading on remote with astro assets

39 messages · Page 1 of 1 (latest)

shadow slate
#

I've tried relative and absolute paths.
I've tried importing with astro::assets, <img /> and markdown (![]()) syntax.

They work locally, but not when the site is hosted on Vercel.
Any ideas to fix are appreciated.

stark jacinthBOT
#
Quiet in here?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

scarlet charm
#

can you post the actual example that failed ?
minmal github repo, or used path, images location, config,...

shadow slate
#

@scarlet charm Here's one.

<Image
    class="max-w-[15rem] mx-auto sm:w-1/4 sm:float-left m-5 sm:m-0 sm:mr-5 rounded-md"
    src="/src/assets/steps/2/judge_XXXXXXXX.jpeg"
    alt="Judge XXXXXXXX"
    format="webp"
    height={426}
    width={340}
/>

This is /src/pages/steps/2.mdx, linking to /src/assets/steps/2/judge_XXXXXXXX.jpeg

#

Here's another one:

![](/src/assets/blog/XXXXXXX-timeline/timeline.png)

Also works on local, not on Vercel.

#
LOCAL 
![](/src/assets/blog/XXXXXXXX-timeline/timeline.png)
NO 
![](../../assets/blog/XXXXXXXX-timeline/timeline.png)
NO 
<img src="/_astro/src/assets/blog/XXXXXXXX-timeline/timeline.hash.png" />
NO 
<img src="/_astro/blog/XXXXXXXX-timeline/timeline.hash.png" />
NO 
<img src="../../assets/blog/XXXXXXXX-timeline/timeline.png" />
LOCAL 
<img src="/src/assets/blog/XXXXXXXX-timeline/timeline.png" />
#

Local:

#

Remote:

#

Images not loading on remote with astro assets

lethal obsidian
#

You're supposed to import the images

#

Strings references are treated as-is, because they're intended for remote (as in http) paths, so in local dev the /src/ paths ends up working due to Vite serving the filesystem directly

#

I'm planning to add a warning for this soon, probably tomorrow...

#

For the Markdown ones, I would need a repo I can look at. Your relative "No" examples should be working as far as I can tell

shadow slate
#

Not for the markdown ones?

lethal obsidian
#

No, for Markdown it should work just using a normal relative path

#

The path is relative to the Markdown file

#

So, content in src/pages referring to images in src/assets would do ![](../assets/image.png)

#

Alternatively, there's an alias provided for that specific folder, ![](~/assets/image.png)

shadow slate
#

So there may be a deeper issue then

#

Because none of the images are showing on the remote instance

#

Not sitewide, looks like just in markdown files.

lethal obsidian
#

If you have a repo I can look at, that'd be great

shadow slate
#

I can't share a repo but I can share whatever files you'd need, after I redact them?

lethal obsidian
#

As long as I have sufficient context it should be fine

#

Like, the Markdown file, general structure of where things are and such

shadow slate
#

Well I'm working in /src/pages/blog/timeline.mdx to add the image /src/assets/blog/timeline/timeline.png

#

Not sure what else to include. The image isn't the problem, I've tried swapping it out. Nothing funky with the path as far as I can tell. Tried several different syntaxes to get the image to load

#

Seems pretty standard

lethal obsidian
#

Do you have the latest version of the MDX integration?

#

Image support was added to it only recently

shadow slate
#

I should, I reinstalled my whole system today lol

#

But I'll double check.

#

I have 0.18.2

lethal obsidian
#

It was added in 0.19.0, released on 13 April

#

That would do it 😅

shadow slate
#

That might be the problem then haha

#

The relative import is working now.