PROJECTS NOTES HOME

Images in org files

water.jpg

1 Display images in org files

To display inline images in org buffer after you have placed some, click C-c C-x C-v.

2 If you have the image with you

To insert an image, do C-u then C-c C-l. easy. if you add a description, it won't show the image, but rather the description with an indication of a link.

[2023-12-14 Thu] or what I use now is yasnippet that looks like such, that is the yasnippet template:

#+attr_html: :width 800px
#+ATTR_ORG: :width 600
[[./static/images/.png]]

Don't forget to modify the path of the image and it will display it.

This - #+attr_html: - tells how wide the image should look in the browser. This - +ATTR_ORG - tells how wide the image should look in the org file inside emacs when you do org-toggle-inline-images.

3 Resizing images in emacs and html

To resize an image, add this to your init:

(setq org-image-actual-width nil)

Then, above EACH and EVERY image add such lines:

#+attr_html: :width 900px
#+ATTR_ORG: :width 600
file:images/smutifruti.png

and now after C-c C-x C-v - images will display nicely, as per your request. Beautiful.

And then make sure to add this to your css so the image would not spill out of the container borders:

img {
  max-width: 100%;
  height: auto;
}

4 If you don't have an image and want to insert a screenshot

Use org-download package. After you install it, run M-x org-download-screenshot.

Then make sure in init file you have specified the directory. If not, it will save images in your current org file directory. It is good if you want to export the file to html later and then maybe even send to someone.

Important - using org-download package in WSL

5 Displaying captions in images

For example:

#+CAPTION: It all started here, in Bali, 2020 :)
#+attr_html: :width 800px
#+ATTR_ORG: :width 600
./media/bali.png