dangom / writefreely.el

*Frictionless* blogging with Org Mode. No setup required.
90 stars 7 forks source link

Convert images to data URIs #16

Open nikclayton opened 5 years ago

nikclayton commented 5 years ago

Since write.as doesn't support hosting images directly, it would be handy if images linked to from the Org file were converted to data: URIs when the content is uploaded.

dangom commented 5 years ago

Converting them to data URIs is easy, the problem is that write.as ignores <img> tags.

#+BEGIN_SRC emacs-lisp :results verbatim :exports both
(defun tob64 (filename)
  (base64-encode-string
   (with-temp-buffer
     (insert-file-contents filename)
     (buffer-string))))

(format "<img src=\"data:image/png;base64,%s\">"
    (tob64 "/path/to/img"))
#+END_SRC

If their snap.as service would offer an API, it'd be possible to upload images and link them. However the service is not free and doesn't have an API yet. An alternative would be imgur, but not sure if that's not against their terms of service. Ideas?

nikclayton commented 5 years ago

I opened an issue over there about that -- https://github.com/writeas/writefreely/issues/80.