Image path for my code

how can i get image path that in assets |
because i want the path for my code to use it as background
i mean path like : assets/img11.png
i tried that but failed
and thanks :slight_smile:

If you click on the uploaded asset in assets you can copy its URL to use in your project.

I know but in canvas i can’t use the URL
So i should use the path
Can i get it ?

Yes, by using assets-lib: see https://glitch.com/~assets-lib

2 Likes

Oh :scream_cat: broo thx …
I tried it but with out var assets … Cuz that it doesn’t work with me .
Thx for help . :+1:

but another question i tried like that :
./assets/11.png
/assets/11.png
assets/11.png
no one works wih me it says that no file in this name ,but im sure that the file name is 11.png in assets . any solution for that ?
ex : https://imgur.com/tvVmz6S

It’s likely the path to the asset isn’t correct. Try prefacing that path with __dirname e.g. path = __dirname + ‘/assets/11.png’.

the err was no such file ‘app/assets/11.png’ for this time :joy:

DM me a join link for your project and I’ll take a look.

Ah, sorry - You’re trying to reference the images using the relative path on the server-side. Assets-lib is for client-side only. For server-side you’d need to copy the images locally, using wget from the console.

I came across this and it answered my problem perfectly, thank you!

hi. try not to respond to conversations that are 4 years old. just like their post using the heart. when you reply it puts the topic at the top of the topic list. which could get annoying for some people.

1 Like

What a condescending tone to bring to an otherwise helpful conversation - yes this topic is 4 years old and yet it STILL helped me and is very useful.

Apologies if my post annoyed you, but do feel free to scroll past in the future and continue your day.

1 Like