Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using images #72

Open
amr66 opened this issue Mar 21, 2024 · 1 comment
Open

Using images #72

amr66 opened this issue Mar 21, 2024 · 1 comment

Comments

@amr66
Copy link

amr66 commented Mar 21, 2024

I'm wondering if it's possible to display images referenced in the MD document. In my case they are saved relative to the document, like this:

![My fancy Image](img/image01.png)
@MercySpectures
Copy link

Yes, it is possible to display images referenced in a Markdown document when the images are saved relative to the document. The Markdown syntax you have used is correct. Here’s how you can ensure the images display correctly:

  1. Correct Path: Make sure the path to the image is correct relative to the location of your Markdown file. For example, if your Markdown file is in the root directory of your project and the image is in an img folder within the same directory, the path img/image01.png is correct.

  2. File Structure: Verify that the image files are indeed located in the specified directory and the filenames match exactly, including the extension and case sensitivity.

  3. Markdown Preview: If you are using a Markdown editor or a viewer (like Visual Studio Code, GitHub, or a static site generator like Jekyll), the images should render automatically if the paths are correct.

Here’s an example of a typical project structure:

project-folder/
│
├── img/
│   └── image01.png
│
└── document.md

And in document.md, you would reference the image like this:

![My fancy Image](img/image01.png)

Common Issues and Solutions

Image Not Displaying

  1. Path Issues: Double-check the path to the image. The path must be relative to the location of the Markdown file.
  2. File Extension: Ensure the file extension is correct (e.g., .png, .jpg) and matches the actual file.
  3. Case Sensitivity: File paths on some systems are case-sensitive, so ensure the filename case matches exactly.

Viewing on Different Platforms

  • Local Editors: Most Markdown editors like Typora, Visual Studio Code, and others will render the images if the paths are correct.
  • GitHub: If you are viewing the Markdown file on GitHub, make sure the images are committed to the repository and the paths are relative to the Markdown file.
  • Static Site Generators: If you are using a static site generator like Jekyll or Hugo, ensure the images are placed in the correct directory as per the generator’s structure and configuration.

Example Markdown Content

Here is a sample content in a Markdown file (document.md):

# My Document

Here is an image:

![My fancy Image](img/image01.png)

Some more content here.

Ensure the directory structure matches and the image file (image01.png) exists within the img folder.

Conclusion

If you follow these guidelines and ensure the paths and filenames are correct, the images should display correctly in your Markdown document across various platforms and editors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants