StartBootstrap / startbootstrap-clean-blog-jekyll

A Jekyll version of the Clean Blog theme by Start Bootstrap
https://startbootstrap.com/themes/clean-blog-jekyll/
MIT License
2.09k stars 2.68k forks source link

Images not displaying #322

Open RosieBraunholtz opened 1 year ago

RosieBraunholtz commented 1 year ago

I can't seem to get local images to display. Images from a website are fine, but when they come from the local folder, nothing comes up.

Here is my folder layout:

in post1.html I've put the line: <img src='/img/img1.jpg'>. This is what I've researched to be correct, but I have also tried <img src='img/img1.jpg'> and <img src='../img/img1.jpg'> and neither of them work either. I have tried putting the image inside the _posts folder to see if that helps, but nothing.

However when I link from a website the image works fine, for example : <img src='https://www.nasa.gov/sites/default/files/thumbnails/image/stsci-01gfnr1kzzp67ffgv8y26kr0vw.png'> shows up with the correct image.

Not sure why it's not working and it's very frustating. I've double checked the spelling and file path a million times. Any help?

Gorlenah commented 1 year ago

Try with:

<img src="/img/img1.jpg" alt="Image Description">

Check that you follow the html rules, the error probably is the use of ' instead of "

alt tag is the description of the image, Alt Tag

To have a responsive image, add the class: class="img-fluid"

Ex: <img class="img-fluid" src="/img/img1.jpg" alt="Image Description">

padmaJS commented 1 year ago

I found out that the src is using an absolute path. But If I put and image background in the front matter, the url is relative. What I meant is <img src="/img/img1.jpg"> for this the path is /img/img1.jpg but for the frontmatter background as /img/background.jpg, this /repositoryname/img/background.jpg relative path is used.

So until I find a better way, I am hardcoding the path i.e. /padma-is-blogging/img/myimage.jpg for every other <img> I use

I can't seem to get local images to display. Images from a website are fine, but when they come from the local folder, nothing comes up.

Here is my folder layout:

  • _posts
    • post1.html
  • img
    • img1.jpg`

in post1.html I've put the line: <img src='/img/img1.jpg'>. This is what I've researched to be correct, but I have also tried <img src='img/img1.jpg'> and <img src='../img/img1.jpg'> and neither of them work either. I have tried putting the image inside the _posts folder to see if that helps, but nothing.

However when I link from a website the image works fine, for example : <img src='https://www.nasa.gov/sites/default/files/thumbnails/image/stsci-01gfnr1kzzp67ffgv8y26kr0vw.png'> shows up with the correct image.

Not sure why it's not working and it's very frustating. I've double checked the spelling and file path a million times. Any help?