The goal is to make a self-contained html file when exporting from orgmode so that the images are intrinsic to the file and a single html file will can be distributed (I am trying to do this for a class I teach and want to give students a single html they can open in a browser).
I found a snippet of code on line that gives the idea of what I want:
#+BEGIN_SRC python :results output html :exports results with open('/home/britt/Pictures/Britt0001.jpg', 'rb') as image: data = image.read() print '<img src="data:image/jpg;base64,%s">' % data.encode("base64") #+END_SRC
And I am trying to get it into elisp and thus remove the dependancy on python and as a step to creating my own elisp function that could have some more detail.
Here is what I have gotten to. Advice appreciated.
#+BEGIN_src elisp :results output html :exports results (setq myim (concat "<img src=\\"data:image/jpg;base64," (tob64 "/home/britt/Pictures/Britt0001.jpg") ">")) (print myim) #+END_SRC
(defun tob64 (filename) (base64-encode-string (with-temp-buffer (insert-file-contents filename) (buffer-string))))
This doesn't give the correct formatting and quoting.
The goal to be worked toward is some variant of
org-html-export-to-html where the elisp function could live and be invoked when an option like
#+OPTIONS: embed-images-on-html-export:t was invoked.
And as an aside, why doesn't the functionality of exporting to html with embedded images already exist in org-mode? Is there some bigger issue that makes this problematic for me to be working towards?