5

A method to add images to markdown files in Github is described here. However, I would like to add images to *.org files in Gitlab (both Github and Gitlab support README.org files, so the solution should be equal for both). I've tried:

[[file:./path/to/file.svg]]
[[sometext][file:./path/to/file.svg]]]
[[file:./path/to/file.svg]][sometext]]

Markdown's format doesn't work either:

![alt text](./path/to/file.svg)

A now removed answer suggested using

![][1]

[1]: ./path/tofile

which doesn't work either.

What is the right way to do it?

Robe
  • 343
  • 5
  • 10

2 Answers2

5

Insetting html works for both Gitlab and Github.

#+html: <p align="center"><img src="path/to/file" /></p>
Robe
  • 343
  • 5
  • 10
  • 1
    Although disappointing, this seems to be the only solution if you want the image to be displayed correctly, as of now. Hopefully support for `#+attr_html` will appear in GitLab and GitHub. I had to add `width=700` inside the img tag, to correct the display. – kotchwane May 18 '21 at 14:49
0
#+caption: <img description> (optional)
#+attr_html: :width 50 px
#+attr_html: :height 50 px
[[<path to image>]]

For more check the orgmode manual.

basquiatraphaeu
  • 525
  • 7
  • 19
  • Your answer seemed promising, but it didn't work on my GitLab instance - image was not resized. Did you try it in a Git context? – kotchwane May 18 '21 at 14:07
  • @kotchwane as of that answer, after trying it for a long time, I gave up and assumed that GitLab engine rendering handles image dimensions itself and completely ignores such attributes. – basquiatraphaeu May 18 '21 at 14:27
  • 2
    There seems to be an issue opened on this subject for GitLab [here](https://gitlab.com/gitlab-org/gitlab/-/issues/30487). So it might work one day - but as of now, it doesn't – kotchwane May 18 '21 at 14:33