xy2z / PineDocs

A fast and lightweight site for viewing files
GNU General Public License v3.0
141 stars 19 forks source link

Relative path for image support #170

Closed Mylloon closed 2 years ago

Mylloon commented 2 years ago

Find images correctly with a relative path to render the image correctly in markdown.

Example:

                ┌────────────────────────────┐
                │                            │
                │   # Here an image          │
                │   ![Image](Folder1/pic.png)│
                │                            │
Root            └────────┬───────────────────┘
  │                      │
  │                      │
  │                      │
  ├───file.md ◄──────────┘
  │
  │
  └───Folder1
      │
      │
      └─────pic.png
xy2z commented 2 years ago

I think this should be possible in index.php by checking if referer is the same as the host, and if it is then get the file from the content dir instead of public dir, that is the best solution i can think of, but it pobably needs some fiddling and testing.

This way it would work for images, audio, video, etc.

But im not sure if browsers can disable the referer? Even if it's the same host.