I'd like to export my org-mode file to HTML and in the middle of it I have added an image. The image I would like to be wrapped in an anchor tag so that when clicked in the HTML opens a "new" tab rather than loading into the current page. Right now I just put the HTML in a separate file and then use #+INCLUDE: directive.

Instead, I'd like to do something all wrapped up nice like:

#+TMPL: (anchor-img "title" "href" "src" "alt")

And that would, when exported, generate the proper HTML.

Is there something like this for org-mode? Is there another way to do this?

  • My guess is that a macro would be the next thing to try. #+macro: img @@html:<a href="$1" target=_blank><img src="$1" alt="$2"/></a>@@ and then you'd invoke it with {{{img(foo.jpg,some alt text)}}} – amitp Mar 23 at 17:07

Your Answer

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

Browse other questions tagged or ask your own question.