sveltesveltekitdirectus

How to load Directus images into a SvelteKit project?


I created a Directus Database, linked it with my sveltekit project. One of the fields on my columns corresponds to images. I try to do the following like the documentation says, yet no image appears.

<img src={"http://localhost:5173/assets/" + image} alt={item} />

The number corresponding to the image appears when inspecting, yet no image to be seen


Solution

  • First: Localhost is not the address, instead you have to use the address of the app.

    src = {"Something.directus.app/assets/" + image}
    

    Second: In Directus you have to enable the visibility of files under permissions.