Fix image previews for download:* org links

This commit is contained in:
Henrik Lissner 2020-04-15 23:47:14 -04:00
parent 582fb285bc
commit afca8f14a1
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 11 additions and 2 deletions

View file

@ -10,3 +10,13 @@
(rassq-delete-all '+org-dragndrop-download-dnd-fn
(copy-alist dnd-protocol-alist))))
(dnd-handle-one-url nil action uri))))
;;;###autoload
(defun +org-dragndrop-image-fn (protocol link _description)
"Return the image associated with the current attachment."
(let ((file (expand-file-name link org-attach-id-dir)))
(when (and (file-exists-p file) (image-type-from-file-name file))
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(buffer-substring-no-properties (point) (point-max))))))