Displaying an image in Jade
Asked Answered
A

2

10

So I have the following Jade code h3(class="text-muted") MedKit that displays the word "MedKit" at the top of a web page and right next to it I want to display an image. How would I go about doing this and how should I upload/save the image I want to display?

Ackley answered 16/2, 2016 at 5:41 Comment(2)
Could you frame your question about one specific problem and post the code that you have attempted to solve it ?Conaway
My specific problem is I don't know how to display an image in JadeAckley
C
20

You can display a image by using the img tag. In jade the syntax looks like:

img.className#IdName(src="/path-to-image.jpg" alt="Image Title")

To display it next to your h3 tag:

.image-block
  h3 Hello
  img.className#IdName(src="/path-to-image.jpg" alt="Image Title")

I suggest you read about piping in jade too. Just ensure that you replace the spaces with tabs else it will give a compilation error.

Conaway answered 17/2, 2016 at 7:17 Comment(0)
E
5

Pug code to display image from db is...

img.image(src='/' + img_path_var )

old jade code

img.image(src='/#{img_path_var}')
Exhibitionist answered 11/6, 2017 at 21:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.