user3697034
user3697034

Reputation: 127

meteor app: images not loading

I'm making a simple chat app with meteor. My HTML is:

<body>
    <h1 align="center">tomomi-chat</h1>
    <img src="original.gif">
    <div class="container" align="center">
    {{>entryfield}}
    </div>
    <br>
    <div class="container">
    {{>messages}}
    </div>  

The image won't load on the local server. As the app is extremely simplistic, there are no folders besides the '.meteor' folder in the directory. The .js, .css, and .html files are all in the app directory.

Even if I host the image and use an external link, the result in the same. Why is meteor blocking images from my app?

deployed: http://tomomi.meteor.com/

Upvotes: 8

Views: 13243

Answers (5)

jhon
jhon

Reputation: 1

If you are Windows 10 user make public folder like that and call it in simple way

enter image description here

enter image description here

Upvotes: 0

Ankur Soni
Ankur Soni

Reputation: 6018

Put assets in PROJECT/public folder and when you specify link in tag, just use "xyz.jpg".

Thats it! The URL does not include /public folder in it. It is very very taken correctly by meteor framework.

CORRECT -> "xyz.jpg"

INCORRECT -> "/public/xyz.jpg"

Upvotes: 2

Gajen Sunthara
Gajen Sunthara

Reputation: 4816

To elaborate on this, I would add images asset directory in the public folder like this and serve it via like this

images/transparent.jpg

enter image description here

Upvotes: 5

Mustafa
Mustafa

Reputation: 1776

Create a /public folder. put your images there.

Upvotes: 3

You should create a folder named public in your application root folder.

From the Meteor documentation:

/public

Files in /public are served to the client as-is. Use this to store assets such as images. For example, if you have an image located at /public/background.png, you can include it in your HTML with or in your CSS with background-image: url(/background.png). Note that /public is not part of the image URL.

Upvotes: 21

Related Questions