Here is some code lightly modified from a comment by Evgeny here:
http://kitchingroup.cheme.cmu.edu/blog/2016/10/29/Sending-html-emails-from-org-mode-with-org-mime/

It seems to do what you want. Of course, I only tested it with one
image, one time, so I hope it works for you too! It assumes png, but it
would not be too hard to generalize.

#+BEGIN_SRC emacs-lisp
(defun org-image-data-uri (path)
  (let ((data (with-temp-buffer (insert-file-contents path) (buffer-string))))
    (concat "<img src=\"" 
            "data:image/png;charset=utf-8;base64,"
            (base64-encode-string (encode-coding-string data 'binary) t)
            "\"/>")))

(defun my-link (link contents info)
  (let ((type (org-element-property :type link))
        (path (org-element-property :path link)))
    (if (and (string= type "file")
             (f-ext? path "png"))
        (org-image-data-uri path)
      (org-html-link link contents info))))

(org-export-define-derived-backend 'my-html 'html
  :translate-alist '((link . my-link)))

(browse-url (org-export-to-file 'my-html "embedded-image.html"))
#+END_SRC

Xebar Saram writes:

> ping anyone :) gotta prepare new assignments for students next week :)
>
> On Sat, Nov 19, 2016 at 7:46 AM, Xebar Saram <zelt...@gmail.com> wrote:
>
>> Hi all
>>
>> i love the option in org revel (reveal_single_file:t) that allows me to
>> export a presentation to my students with image support embedded in the
>> html file./
>>
>> ive searched for a way to do it in the normal org to html exporter with no
>> success. any clue how that can be done?
>>
>> best
>>
>> Z
>>


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

Reply via email to