I want to create clickable image links in org-mode. This would be equivalent to:

<a href="path-to-file">
   <img src="path-to-image">

Currently, I can display inline image previews just fine, with [[path-to-image]] followed by org-toggle-inline-images. What I would like to do now, is add support for [[path-to-file][path-to-image]].

Any ideas?

  • If I understand correctly this is a feature of github own org exporter, not of org-mode in emacs. – JeanPierre Sep 3 '16 at 20:52
  • Ah. My bad. Hmm... any ideas how to get this to work in org-mode? – Adam Sep 3 '16 at 21:12
  • To clarify, your ideal answer would add support for [[path-to-file][path-to-image]] but would you accept a workaround until that feature is added to the exporter? – Melioratus Feb 11 '17 at 21:58
  • Sure! What have you got? – Adam Feb 12 '17 at 1:55

It can be be done using a macro:

#+MACRO: imglnk @@html:<a href="$1"><img src="$2"></a>@@

This is an image link: {{{imglnk(path-to-file,path-to-image)}}}
  • Note: This doesn't work when viewed in emacs, and presumably needs to be exported to HTML. – HappyFace Oct 7 '20 at 10:52

Org Mode already supports embedding images in exported HTML.

The inline preview functionality does not work for remote images (i.e. those found on the internet). See the question about this. Preview does work for local images, as I think you already know.

  • 3
    Thanks. Yes, I can get an image to display in the buffer just fine. But what I want to do is Create an image link so that clicking on the inline image opens a separate file (or URL). For example, embedding a screen grab from a video and then clicking it plays a QuickTime file. The html equivalent can be found here: w3schools.com/tags/tryit.asp?filename=tryhtml_link_image – Adam Sep 4 '16 at 14:15
  • 2
    So something like this [[file:movie.mp4][file:screengrab.png]] where the screen grab is previewed in the buffer and on clicking it, the movie file opens in its default application. – Adam Sep 4 '16 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.