Cordova image load problem

Hi,

I know this is a very common problem, but I couldn’t solve it with the suggested solutions

Development
<img src="@/assets/trendyol.jpg" width="50" />

Production
<img src="assets/trendyol.6ccd0da2.jpg" width="50">

Use the public folder for static images.

Put files public/static/img/ and Call src like “./static/img/test.img”

Thank you for your help.
But it didn’t.
I guess there is another problem. Images moved to cordova but cannot be displayed.

Un cordova i creare a folder inside WWW an works fine.
www/img/image_name.jpg

AND call src=“img/image_name.jpg”

I wouldn’t recommend using the file:// system to preview your Android app. Use the Cordova simulator instead so it runs on HTTP requests.

Actually the images are moved under www. If I do this manually, I guess the same thing will happen.

Thanks for the suggestion,i have not used before. I will use

I solved it this way

//import.meta.url is vite property
function(image){
     return  new URL(`../../assets/images/${image}`, import.meta.url).href
}
1 Like