org-download

a fork of abo-abo's org-download
git clone https://git.trogloxene.org/org-download.git
Log | Files | Refs | README

commit 37d323034b09fe17029985aa556999acb2f9a0e5
parent 06e39cb93b18676c62d175a834d382cb47a64268
Author: Oleh Krehel <ohwoeowho@gmail.com>
Date:   Sat, 19 Nov 2016 12:15:37 +0100

Add support for inline "data:image/png;base64," links

Fixes #39

Diffstat:
Morg-download.el | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/org-download.el b/org-download.el @@ -426,13 +426,27 @@ Otherwise, pass URI and ACTION back to dnd dispatch." (expand-file-name filename)) t t))) +(defun org-download-dnd-base64 (uri action) + (when (eq major-mode 'org-mode) + (when (string-match "^data:image/png;base64," uri) + (let* ((me (match-end 0)) + (filename (org-download--fullname + (substring-no-properties uri me (+ me 10)) + "png"))) + (with-temp-buffer + (insert (base64-decode-string (substring uri me))) + (write-file filename)) + (org-download-insert-link filename filename))))) + ;;;###autoload (defun org-download-enable () "Enable org-download." (unless (eq (cdr (assoc "^\\(https?\\|ftp\\|file\\|nfs\\):" dnd-protocol-alist)) 'org-download-dnd) (setq dnd-protocol-alist - `(("^\\(https?\\|ftp\\|file\\|nfs\\):" . org-download-dnd) ,@dnd-protocol-alist)))) + `(("^\\(https?\\|ftp\\|file\\|nfs\\):" . org-download-dnd) + ("^data:" . org-download-dnd-base64) + ,@dnd-protocol-alist)))) (defun org-download-disable () "Disable org-download."