commit a367669384859261bcb11bac4b782f231f972353 parent f434cec862e8d1d3b58573ab81078a4297315edc Author: Feng Shu <tumashu@163.com> Date: Wed, 4 Dec 2019 09:10:10 +0800 org-download.el (org-download-link-format-function): Add Fixes #113 Diffstat:
| M | org-download.el | | | 20 | ++++++++++++++++---- |
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/org-download.el b/org-download.el @@ -379,6 +379,21 @@ It's inserted before the image link and is used to annotate it.") "[[file:%s]]\n" "Format of the file link to insert.") +(defcustom org-download-link-format-function #'org-download-link-format-function-default + "Function that takes FILENAME and returns a org link." + :type 'function) + +(defun org-download-link-format-function-default (filename) + "The default function of `org-download-link-format-function'." + (if (and (>= (string-to-number org-version) 9.3) + (eq org-download-method 'attach)) + (format "[[attachment:%s]]\n" + (org-link-escape + (file-relative-name filename (org-attach-dir)))) + (format org-download-link-format + (org-link-escape + (funcall org-download-abbreviate-filename-function filename))))) + (defun org-download-image (link) "Save image at address LINK to `org-download--dir'." (interactive "sUrl: ") @@ -484,10 +499,7 @@ It's inserted before the image link and is used to annotate it.") (insert (if (= org-download-image-org-width 0) "" (format "#+attr_org: :width %dpx\n" org-download-image-org-width))) - (insert - (format org-download-link-format - (org-link-escape - (funcall org-download-abbreviate-filename-function filename)))) + (insert (funcall org-download-link-format-function filename)) (org-download--display-inline-images) (setq str (buffer-substring-no-properties line-beg (point))) (when in-item-p