Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make inline images responsive in org-mode?

Tags:

emacs

org-mode

When I toggle inline image using org-toggle-inline-images which shows the image(s). However, when the image it too large it will overflow the editor's frame (See screenshot below).

enter image description here

How to make the image responsive which means the max size of the image should never exceed the width of window size.

Of course, I can use the code below to fix the size of the image. But what I truly want is some kind of responsive image displaying.

(setq org-mode-actual-width 600)

enter image description here

Thanks for your time viewing this question.

like image 228
X.Creates Avatar asked Apr 07 '16 02:04

X.Creates


1 Answers

From the documentation of org-image-actual-width:

Documentation:
Should we use the actual width of images when inlining them?

When set to t, always use the image width.

When set to a number, use imagemagick (when available) to set
the image's width to this value.

When set to a number in a list, try to get the width from any
#+ATTR.* keyword if it matches a width specification like

  #+ATTR_HTML: :width 300px

and fall back on that number if none is found.

When set to nil, try to get the width from an #+ATTR.* keyword
and fall back on the original width if none is found.

So you could use the attribute #+ATTR_HTML to specify the width. It has to be specified manually though. Is this responsive enough?

like image 177
Dominik Schrempf Avatar answered Oct 06 '22 00:10

Dominik Schrempf