Inserting image in pug template engine

I am working with PUG template engine,Unable to insert image. I have my image stored in current folder where this file is stored. Any help would be appreciated. Unable to load image. Following is the code written for image.

img(src='./login_icon', alt='login', style='width:100px;height:100px;')

Upvotes: 2

Views: 16231

Answers (3)

Maurovez
Maurovez

Reputation: 51

What I can see in your example is that it doesn't have the image extension.

img(src='./login_icon.svg' alt='login' style='width:100px;height:100px;')

Check that and also the path of it.

Upvotes: 0

Al-ameen Ademola
Al-ameen Ademola

Reputation: 1

If you're working on node.js. move to your server.js and add this code.

app.use('/pictures', express.static(process.cwd() + '/pictures'));

where pictures is the picture folder

img(src='./Pictures/pic1')

this in your .pub file

Upvotes: 0

ize
ize

Reputation: 51

It should be:

img(src='./login_icon' alt='login' style='width:100px; height:100px;')

Simply remove the comma.

Upvotes: 5

Related Questions