Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow including images with relative paths in rendered pages (e.g. markdown) #244

Open
s-ol opened this issue Oct 5, 2019 · 3 comments
Open

Comments

@s-ol
Copy link
Contributor

s-ol commented Oct 5, 2019

On github it is common to include images in the README.md, like so:

https://git.s-ol.nu/janko-keystep-rgb/blob/master/README.md

![](doc/wiring.png)

this currently creates the right markup:

<img alt="" src="doc/wiring.png">

however the browser then request the image at https://git.s-ol.nu/janko-keystep-rgb/blob/master/doc/wiring.png, where he gets served the HTML page showing the image, instead of the raw image with the correct mime type.

I see two solutions:

  1. Detect this situation when rendering the markup and change the src to point to .../raw/master/doc/wiring.png. This seems to be what github does.
  2. Leave the renderer alone and look at the incoming request, when chromium loads the image it sends an Accept: accept: image/webp,image/apng,image/*,*/*;q=0.8 header that clarifies that it is looking for an image, and even explicitly states that anything else (like text/html) will only partially satisfy (q=0.8). This could be detected and the file server raw in that case.
@jonashaag
Copy link
Owner

I agree that we should fix this and I'm happy with both ways, but strong preference for 1.) because it is much simpler (though maybe not easier to implement)

@cpressey
Copy link
Contributor

cpressey commented Oct 7, 2019

For whatever it's worth, I faced the same problem, and took this approach to solving it:

Github honours ?raw=true in requests for files; compare

So what I did was

Happy to open a PR with that change, but I suspect most users would prefer a "smarter" solution that doesn't require they add querystrings to their image links.

@jonashaag
Copy link
Owner

but I suspect most users would prefer a "smarter" solution that doesn't require they add querystrings to their image links.

Indeed 8-)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants