Fix image previews for download:* org links
This commit is contained in:
parent
582fb285bc
commit
afca8f14a1
2 changed files with 11 additions and 2 deletions
|
@ -10,3 +10,13 @@
|
||||||
(rassq-delete-all '+org-dragndrop-download-dnd-fn
|
(rassq-delete-all '+org-dragndrop-download-dnd-fn
|
||||||
(copy-alist dnd-protocol-alist))))
|
(copy-alist dnd-protocol-alist))))
|
||||||
(dnd-handle-one-url nil action uri))))
|
(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))))))
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
(after! org
|
(after! org
|
||||||
;; A shorter link to attachments
|
;; A shorter link to attachments
|
||||||
(+org-def-link "download" org-attach-id-dir)
|
(+org-def-link "download" org-attach-id-dir)
|
||||||
(setf (alist-get "download" org-link-abbrev-alist nil nil #'equal)
|
(org-link-set-parameters "download" :image-data-fun #'+org-dragndrop-image-fn))
|
||||||
(abbreviate-file-name org-attach-id-dir)))
|
|
||||||
:config
|
:config
|
||||||
(setq org-download-image-dir org-attach-id-dir
|
(setq org-download-image-dir org-attach-id-dir
|
||||||
org-download-link-format "[[download:%s]]\n"
|
org-download-link-format "[[download:%s]]\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue