fix(org): attachment image inline preview
Fix originally proposed by Khoulaiz here: https://github.com/doomemacs/doomemacs/issues/7222#issuecomment-1535932540 Fix: #7222 #3185 Co-authored-by: Andreas Sahlbach <Khoulaiz>
This commit is contained in:
parent
42ae401deb
commit
d2efb01d29
2 changed files with 9 additions and 11 deletions
|
@ -316,16 +316,14 @@ exist, and `org-link' otherwise."
|
||||||
(defun +org-image-file-data-fn (protocol link _description)
|
(defun +org-image-file-data-fn (protocol link _description)
|
||||||
"Intepret LINK as an image file path and return its data."
|
"Intepret LINK as an image file path and return its data."
|
||||||
(setq
|
(setq
|
||||||
link (expand-file-name
|
|
||||||
link (pcase protocol
|
link (pcase protocol
|
||||||
("download"
|
("download"
|
||||||
(or (if (require 'org-download nil t) org-download-image-dir)
|
(expand-file-name link (or (if (require 'org-download nil t) org-download-image-dir)
|
||||||
(if (require 'org-attach) org-attach-id-dir)
|
default-directory)))
|
||||||
default-directory))
|
|
||||||
("attachment"
|
("attachment"
|
||||||
(require 'org-attach)
|
(require 'org-attach)
|
||||||
org-attach-id-dir)
|
(org-attach-expand link))
|
||||||
(_ default-directory))))
|
(_ (expand-file-name link default-directory))))
|
||||||
(when (and (file-exists-p link)
|
(when (and (file-exists-p link)
|
||||||
(image-type-from-file-name link))
|
(image-type-from-file-name link))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
|
|
@ -494,7 +494,7 @@ relative to `org-directory', unless it is an absolute path."
|
||||||
(add-to-list 'projectile-globally-ignored-directories org-attach-id-dir)))
|
(add-to-list 'projectile-globally-ignored-directories org-attach-id-dir)))
|
||||||
|
|
||||||
;; Add inline image previews for attachment links
|
;; Add inline image previews for attachment links
|
||||||
(org-link-set-parameters "attachment" :image-data-fun #'+org-inline-image-data-fn))
|
(org-link-set-parameters "attachment" :image-data-fun #'+org-image-file-data-fn))
|
||||||
|
|
||||||
|
|
||||||
(defun +org-init-custom-links-h ()
|
(defun +org-init-custom-links-h ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue