Where to put my local image?


#1

I put image in public/assets/images/image1.jpg

in template some_text

but I get 404 not found this image?why?


#2

Read the first couple sentences of http://ember-cli.com/user-guide/#asset-compilation


#3

this is my code in template

<img src="assets/images/image1.jpg" > but not see anything

and console print this http://localhost:4200/assets/images/image1.jpg [HTTP/1.1 404 Not Found 3079ms]


#4

They go in the public folder


#5

Would you give me a complete example of local image usage,please?


#6

in http://ember-cli.com/user-guide/#asset-compilation explaination is too embigulous to let me know


#7
For example, if you place logo.png in public/assets/images, you can reference it in templates with assets/images/logo.png or in stylesheets with url('/assets/images/logo.png')

Please let us know what part is ambiguous. We want to be clear.


#8

so this is wrong(beginner way to use tag ‘img’)

The website don’t say “must” use in stylesheets with url(’/assets/images/logo.png’) ,it is my misunderstand on tag ‘img’


#9

No it’s not wrong to use an img tag.


#10

finaly I found <img src="assets/images/image1.jpg" alt="some_text" /> is okay . The css way is OK too. Because in “/>” The / is what I lost key in . (so sily)


#11

Nice information.

In my app, I code url as follows respectively in css file and js file, and they works well in browsers of both PC and mobile device, and in a cordova app as well.

In app.css

 #btnPlay {
    background:url(media/images/play-sm.png)

In app.js

 let btnA = document.getElementById('btnPlay');
 btnPlay.background = "url(assets/media/images/play-sm.png)";

#12

Actually, in ember 2.7.0, <img src="assets/image/image.png"> doesn’t work (it generates a 404 in nested routes) but <img src="/assets/image/image.png"> (with / before assets) works.